def METHOD_NAME(param=None):
    werkzeug_logger_to_error()
    configure_root_logger()
    dci_app = DciControlServer()
    dci_app.url_map.converters["uuid"] = utils.UUIDConverter
    logger.info("dci control server startup")
    def handle_api_exception(api_exception):
        response = flask.jsonify(api_exception.to_dict())
        response.status_code = api_exception.status_code
        logger.exception(api_exception)
        return response
    def handle_dbapi_exception(dbapi_exception):
        db_exception = exceptions.DCIException(str(dbapi_exception)).to_dict()
        response = flask.jsonify(db_exception)
        response.status_code = 400
        logger.exception(dbapi_exception)
        return response
    @dci_app.before_request
    def before_request():
        flask.g.team_admin_id = dci_app.team_admin_id
        flask.g.team_redhat_id = dci_app.team_redhat_id
        flask.g.team_epm_id = dci_app.team_epm_id
        for i in range(5):
            try:
                flask.g.engine = dci_app.engine
                flask.g.db_conn = dci_app.engine.connect()
                flask.g.session = sessionmaker(bind=dci_app.engine)()
                break
            except Exception:
                logging.warning(
                    "failed to connect to the database, " "will retry in 1 second..."
                )
                time.sleep(1)
                pass
        flask.g.store = dci_app.store
        flask.g.sender = dci_app.sender
    @dci_app.teardown_request
    def teardown_request(_):
        try:
            flask.g.session.close()
        except Exception:
            logging.warning(
                "There's been an arror while calling session.close() in teardown_request."
            )
        try:
            flask.g.db_conn.close()
        except Exception:
            logging.warning(
                "There's been an error while calling db_conn.close() in teardown_request."
            )
    # Registering REST error handler
    dci_app.register_error_handler(exceptions.DCIException, handle_api_exception)
    dci_app.register_error_handler(sa_exc.DBAPIError, handle_dbapi_exception)
    # Registering REST API v1
    dci_app.register_blueprint(api_v1.api, url_prefix="/api/v1")
    # Registering custom encoder
    dci_app.json_encoder = utils.JSONEncoder
    return dci_app