Fix wsgi_script entry point

Previously the wsgi_script openstack-health entry point was pointing
directly to flask app object in the api module. However the script
constructed by pbr attempts to call app and set that as the
application for mod_wsgi. However this is the incorrect usage for a
flask app, and will fail because the app object isn't expected to be
called by itself without any args) Also, according to the flask docs
[1] you just need to set the flask app as the application var in the
to run with mod_wsgi. This commit fixes the wsgi_script entrypoint by
creating a wrapper function which can be called by the generated
output of wsgi scripts from pbr and will return the flask app. This
function is then used as the wsgi_script entrypoint instead of the app
itself. Additionally, this also gives a good injection point if there
are any future initialization or configuration steps that need to be
taken when running.

[1] http://flask.pocoo.org/docs/0.10/deploying/mod_wsgi/#creating-a-wsgi-file

Change-Id: I6e49b4dbbe58e054a28412207b99eb2982a45fbe
This commit is contained in:
Matthew Treinish 2015-10-10 00:32:04 -04:00
parent 28a7983234
commit d0a65e31ca
No known key found for this signature in database
GPG Key ID: FD12A0F214C9E177
2 changed files with 5 additions and 1 deletions

View File

@ -33,6 +33,10 @@ engine = None
Session = None
def get_app():
return app
@app.before_first_request
def setup():
config = ConfigParser.ConfigParser()

View File

@ -27,7 +27,7 @@ console_scripts =
openstack-health-api = openstack_health.api:main
wsgi_scripts =
openstack-health = openstack_health.api:app
openstack-health = openstack_health.api:get_app
[build_sphinx]
all_files = 1