From 257fb556355359e0faaaa7596ba8a9c2dd0fd973 Mon Sep 17 00:00:00 2001 From: Johannes Grassler Date: Wed, 13 Sep 2017 15:27:43 +0200 Subject: [PATCH] Fix WSGI application * Partial revert of 0a82af18abbf070a058cb757af68926f9b66798f to restore main() method * Add global `application` variable which will be set by main method to problem to preserve the fix from 0a82af18abbf070a058cb757af68926f9b66798f. * Add check for application name starting with '_mod_wsgi' to ensure application runs in Devstack as well (Devstack does not use the entry point) * Modify Devstack plugin to run WSGI entry point rather than app/wsgi.py from module directory. Change-Id: I07001dccb663ed4e6e3347089ab96e6f8ec196d4 Story: 2001197 Task: 5702 --- devstack/plugin.sh | 2 +- monasca_log_api/app/wsgi.py | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/devstack/plugin.sh b/devstack/plugin.sh index 939ca523..a775d9b0 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -258,7 +258,7 @@ function configure_monasca_log_api_wsgi { fi # copy proxy vhost and wsgi helper files - sudo cp $MONASCA_LOG_API_DIR/monasca_log_api/app/wsgi.py $MONASCA_LOG_API_WSGI_DIR/monasca_log_api + sudo cp $MONASCA_LOG_API_BIN_DIR/monasca-log-api-wsgi $MONASCA_LOG_API_WSGI_DIR/monasca_log_api sudo cp $PLUGIN_FILES/apache-log-api.template $monasca_log_api_apache_conf sudo sed -e " s|%PUBLICPORT%|$monasca_log_api_api_port|g; diff --git a/monasca_log_api/app/wsgi.py b/monasca_log_api/app/wsgi.py index 3bfcad6c..61cd25fc 100644 --- a/monasca_log_api/app/wsgi.py +++ b/monasca_log_api/app/wsgi.py @@ -18,6 +18,15 @@ Use this file for deploying the API under mod_wsgi. from paste import deploy -base_dir = '/etc/monasca/' -conf = '%slog-api-paste.ini' % base_dir -application = deploy.loadapp('config:%s' % conf) +application = None + + +def main(): + base_dir = '/etc/monasca/' + conf = '%slog-api-paste.ini' % base_dir + app = deploy.loadapp('config:%s' % conf) + return app + + +if __name__ == '__main__' or __name__.startswith('_mod_wsgi'): + application = main()