From ecf76ae7d71c29c6ba802de42599a0a9d8358f26 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Tue, 26 Nov 2024 10:58:22 +0900 Subject: [PATCH] Use module path to load wsgi application devstack is now replacing usage of wsgi script by wsgi module. This replaces the way to load the api wsgi app following that transition. Change-Id: Id799bacb71483d2e337c049e1db7f85735eb5a1e --- devstack/settings | 2 +- zaqar/transport/wsgi/app.py | 35 ++++++++++++++++++++++++----------- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/devstack/settings b/devstack/settings index 0366d90ca..f4852ea20 100644 --- a/devstack/settings +++ b/devstack/settings @@ -7,7 +7,7 @@ ZAQAR_CONF_DIR=/etc/zaqar ZAQAR_CONF=$ZAQAR_CONF_DIR/zaqar.conf ZAQAR_POLICY_CONF=$ZAQAR_CONF_DIR/policy.yaml ZAQAR_UWSGI_CONF=$ZAQAR_CONF_DIR/uwsgi.conf -ZAQAR_UWSGI=$ZAQAR_DIR/zaqar/transport/wsgi/app.py +ZAQAR_UWSGI=zaqar.transport.wsgi.app:application ZAQAR_API_LOG_DIR=/var/log/zaqar ZAQAR_API_LOG_FILE=$ZAQAR_API_LOG_DIR/queues.log ZAQAR_AUTH_CACHE_DIR=${ZAQAR_AUTH_CACHE_DIR:-/var/cache/zaqar} diff --git a/zaqar/transport/wsgi/app.py b/zaqar/transport/wsgi/app.py index ff4909114..8fcf1f26c 100644 --- a/zaqar/transport/wsgi/app.py +++ b/zaqar/transport/wsgi/app.py @@ -26,6 +26,8 @@ no common way to specify / pass configuration files to the WSGI app when it is called from other apps. """ +import threading + from oslo_config import cfg from oslo_log import log from oslo_reports import guru_meditation_report as gmr @@ -35,16 +37,27 @@ from zaqar import bootstrap from zaqar import version # Use the global CONF instance -conf = cfg.CONF -gmr_opts.set_defaults(conf) -log.register_options(conf) -conf(project='zaqar', prog='zaqar-queues', args=[]) -log.setup(conf, 'zaqar') +CONF = cfg.CONF -gmr.TextGuruMeditation.setup_autorun(version, conf=conf) -boot = bootstrap.Bootstrap(conf) -conf.drivers.transport = 'wsgi' -application = boot.transport.app -# Keep the old name for compatibility -app = application +def init_application(): + gmr_opts.set_defaults(CONF) + log.register_options(CONF) + CONF(project='zaqar', prog='zaqar-queues', args=[]) + log.setup(CONF, 'zaqar') + + gmr.TextGuruMeditation.setup_autorun(version, conf=CONF) + + boot = bootstrap.Bootstrap(CONF) + CONF.drivers.transport = 'wsgi' + return boot.transport.app + + +app = application = None + +lock = threading.Lock() +with lock: + if application is None: + application = init_application() + # Keep the old name for compatibility + app = application