Merge "Use module path to load wsgi application"

This commit is contained in:
Zuul 2025-01-06 05:14:21 +00:00 committed by Gerrit Code Review
commit 09a5ec9d90
2 changed files with 25 additions and 12 deletions

View File

@ -7,7 +7,7 @@ ZAQAR_CONF_DIR=/etc/zaqar
ZAQAR_CONF=$ZAQAR_CONF_DIR/zaqar.conf ZAQAR_CONF=$ZAQAR_CONF_DIR/zaqar.conf
ZAQAR_POLICY_CONF=$ZAQAR_CONF_DIR/policy.yaml ZAQAR_POLICY_CONF=$ZAQAR_CONF_DIR/policy.yaml
ZAQAR_UWSGI_CONF=$ZAQAR_CONF_DIR/uwsgi.conf 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_DIR=/var/log/zaqar
ZAQAR_API_LOG_FILE=$ZAQAR_API_LOG_DIR/queues.log ZAQAR_API_LOG_FILE=$ZAQAR_API_LOG_DIR/queues.log
ZAQAR_AUTH_CACHE_DIR=${ZAQAR_AUTH_CACHE_DIR:-/var/cache/zaqar} ZAQAR_AUTH_CACHE_DIR=${ZAQAR_AUTH_CACHE_DIR:-/var/cache/zaqar}

View File

@ -26,6 +26,8 @@ no common way to specify / pass configuration files
to the WSGI app when it is called from other apps. to the WSGI app when it is called from other apps.
""" """
import threading
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log from oslo_log import log
from oslo_reports import guru_meditation_report as gmr from oslo_reports import guru_meditation_report as gmr
@ -35,16 +37,27 @@ from zaqar import bootstrap
from zaqar import version from zaqar import version
# Use the global CONF instance # Use the global CONF instance
conf = cfg.CONF CONF = cfg.CONF
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) def init_application():
conf.drivers.transport = 'wsgi' gmr_opts.set_defaults(CONF)
application = boot.transport.app log.register_options(CONF)
# Keep the old name for compatibility CONF(project='zaqar', prog='zaqar-queues', args=[])
app = application 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