Fix WSGI script for gunicorn

The previous patch to add support for apache breaks gunicorn. The gunicorn
setup loads the mistral.api.wsgi module and requires the application
variable be assigned. The support for apache make the assumption that the
mistral.api.wsgi be called as a python script. This patch moves the init
function required by apache to a different location.

Change-Id: Ib5af50a55d3f3bb9d0fa0d1ee6b8e7564f909d70
Closes-Bug: #1689943
This commit is contained in:
Winson Chan 2017-05-10 21:31:42 +00:00
parent 2a2c8e733b
commit b6de4720db
3 changed files with 11 additions and 14 deletions

View File

@ -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()

View File

@ -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()

View File

@ -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