From 0d39f3535d674d221a976a251dd85f95af44981d Mon Sep 17 00:00:00 2001 From: Thomas Goirand Date: Fri, 17 May 2019 11:26:42 +0200 Subject: [PATCH] Make it possible to use uwsgi easily This patch adds a standard /usr/bin/magnum-api-uwsgi script, which we can use from uwsgi. Without this patch, there's no way to load the application correctly, with parameters on the command line. Change-Id: Icdcd1255e7e08d68a5d31672b21127f781d6ac68 --- magnum/api/app.py | 7 +++++++ setup.cfg | 3 +++ 2 files changed, 10 insertions(+) diff --git a/magnum/api/app.py b/magnum/api/app.py index cae197aa63..1d7e8e2fd2 100755 --- a/magnum/api/app.py +++ b/magnum/api/app.py @@ -10,6 +10,7 @@ # See the License for the specific language governing permissions and # limitations under the License. import os +import sys from oslo_config import cfg from oslo_log import log @@ -19,6 +20,7 @@ import pecan from magnum.api import config as api_config from magnum.api import middleware from magnum.common import config as common_config +from magnum.common import service import magnum.conf CONF = magnum.conf.CONF @@ -65,3 +67,8 @@ def load_app(): def app_factory(global_config, **local_conf): return setup_app() + + +def build_wsgi_app(argv=None): + service.prepare_service(sys.argv) + return load_app() diff --git a/setup.cfg b/setup.cfg index f0e8860e6e..062a843428 100644 --- a/setup.cfg +++ b/setup.cfg @@ -47,6 +47,9 @@ console_scripts = magnum-driver-manage = magnum.cmd.driver_manage:main magnum-status = magnum.cmd.status:main +wsgi_scripts = + magnum-api-wsgi = magnum.api.app:build_wsgi_app + oslo.config.opts = magnum = magnum.opts:list_opts magnum.conf = magnum.conf.opts:list_opts