diff --git a/mistral/api/app.py b/mistral/api/app.py index 3156e2697..d3fdf02bb 100644 --- a/mistral/api/app.py +++ b/mistral/api/app.py @@ -83,3 +83,12 @@ def setup_app(config=None): # Create a CORS wrapper, and attach mistral-specific defaults that must be # included in all CORS responses. return cors_middleware.CORS(app, cfg.CONF) + + +def init_wsgi(): + # By default, oslo.config parses the CLI args if no args is provided. + # As a result, invoking this wsgi script from gunicorn leads to the error + # with argparse complaining that the CLI options have already been parsed. + m_config.parse_args(args=[]) + + return setup_app() diff --git a/mistral/api/wsgi.py b/mistral/api/wsgi.py index 949d9b522..27866f0c1 100644 --- a/mistral/api/wsgi.py +++ b/mistral/api/wsgi.py @@ -13,17 +13,5 @@ # limitations under the License. from mistral.api import app -from mistral import config - -# By default, oslo.config parses the CLI args if no args is provided. -# As a result, invoking this wsgi script from gunicorn leads to the error -# with argparse complaining that the CLI options have already been parsed. -def init_application(): - config.parse_args(args=[]) - - return app.setup_app() - - -if __name__ == '__main__': - application = init_application() +application = app.init_wsgi() diff --git a/setup.cfg b/setup.cfg index b9bfc51dd..d58f95b95 100644 --- a/setup.cfg +++ b/setup.cfg @@ -38,7 +38,7 @@ console_scripts = mistral-db-manage = mistral.db.sqlalchemy.migration.cli:main wsgi_scripts = - mistral-wsgi-api = mistral.api.wsgi:init_application + mistral-wsgi-api = mistral.api.app:init_wsgi mistral.rpc.backends = oslo_client = mistral.rpc.oslo.oslo_client:OsloRPCClient