From f7aa502e3c62e8fd599e06bdd870a20e8437c90b Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Tue, 26 Nov 2024 10:50:32 +0900 Subject: [PATCH] Add wsgi module The wsgi_script feature is being removed because of some changes in underlying python packaging tooling. This makes aodh to vendor the wsgi module which can be used instead of the wsgi script, according to the proposed community goal[1]. The existing wsgi scripts are kept now for smooth transition. The exsiting app.wsgi file is deprecated in favor of the new wsgi module to follow the standard pattern to vendor the wsgi module. [1] https://review.opendev.org/c/openstack/governance/+/902807 Change-Id: I7ce471c7fbce960ba92bfd18203a73454088314e --- aodh/api/app.wsgi | 4 ++++ aodh/wsgi/__init__.py | 0 aodh/wsgi/api.py | 22 ++++++++++++++++++++++ devstack/settings | 2 +- 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 aodh/wsgi/__init__.py create mode 100644 aodh/wsgi/api.py diff --git a/aodh/api/app.wsgi b/aodh/api/app.wsgi index fb8eb6030..93641b215 100644 --- a/aodh/api/app.wsgi +++ b/aodh/api/app.wsgi @@ -19,5 +19,9 @@ See http://pecan.readthedocs.org/en/latest/deployment.html for details. """ from aodh.api import app +import warnings + + +warnings.warn('Using app.wsgi is deprecated. Use aodh.wsgi.api instead') application = app.build_wsgi_app(argv=[]) diff --git a/aodh/wsgi/__init__.py b/aodh/wsgi/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/aodh/wsgi/api.py b/aodh/wsgi/api.py new file mode 100644 index 000000000..ac6f8ddd3 --- /dev/null +++ b/aodh/wsgi/api.py @@ -0,0 +1,22 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +"""WSGI application entry-point for Aodh API.""" + +import threading + +from aodh.api import app + + +application = None +with threading.Lock(): + if application is None: + application = app.build_wsgi_app(argv=[]) diff --git a/devstack/settings b/devstack/settings index 3cc49e5a1..d6fa91c5b 100644 --- a/devstack/settings +++ b/devstack/settings @@ -11,7 +11,7 @@ AODH_DIR=$DEST/aodh AODH_CONF_DIR=/etc/aodh AODH_CONF=$AODH_CONF_DIR/aodh.conf AODH_UWSGI_CONF=$AODH_CONF_DIR/aodh-uwsgi.ini -AODH_UWSGI=$AODH_DIR/aodh/api/app.wsgi +AODH_UWSGI=aodh.wsgi.api:application # Set up database backend AODH_BACKEND=${AODH_BACKEND:-mysql}