From 4504bd5a8d17da2f11689215108d79353cc3fbf1 Mon Sep 17 00:00:00 2001 From: Dmitry Tantsur Date: Fri, 24 Jan 2020 12:19:05 +0100 Subject: [PATCH] Make ironic-api compatible with WSGI containers other than mod_wsgi Using ironic-api-wsgi implies mod_wsgi, some other containers require an importable module. This patch modifies ironic.api.wsgi to be usable this way and documents it. Change-Id: I8493eb36293a0214081e0adb59c3a267c9688819 --- .../include/configure-ironic-api-mod_wsgi.inc | 17 +++++++++++++++++ ironic/api/wsgi.py | 5 +++-- .../notes/any-wsgi-8d6ccb0590104146.yaml | 7 +++++++ 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/any-wsgi-8d6ccb0590104146.yaml diff --git a/doc/source/install/include/configure-ironic-api-mod_wsgi.inc b/doc/source/install/include/configure-ironic-api-mod_wsgi.inc index bbfa79be73..e881a07692 100644 --- a/doc/source/install/include/configure-ironic-api-mod_wsgi.inc +++ b/doc/source/install/include/configure-ironic-api-mod_wsgi.inc @@ -74,3 +74,20 @@ Bare Metal service comes with an example file for configuring the .. note:: The file ``ironic-api-wsgi`` is automatically generated by pbr and is available in `IRONIC_BIN` directory. It should not be modified. + +Configure another WSGI container +-------------------------------- + +A slightly different approach has to be used for WSGI containers that cannot +use ``ironic-api-wsgi``. For example, for *gunicorn*: + +.. code-block:: console + + gunicorn -b 0.0.0.0:6385 'ironic.api.wsgi:initialize_wsgi_app(argv=[])' + +If you want to pass a configuration file, use: + +.. code-block:: console + + gunicorn -b 0.0.0.0:6385 \ + 'ironic.api.wsgi:initialize_wsgi_app(argv=["ironic-api", "--config-file=/path/to/_ironic.conf"])' diff --git a/ironic/api/wsgi.py b/ironic/api/wsgi.py index 851319d740..210a16a847 100644 --- a/ironic/api/wsgi.py +++ b/ironic/api/wsgi.py @@ -25,10 +25,11 @@ CONF = cfg.CONF LOG = log.getLogger(__name__) -def initialize_wsgi_app(): +# NOTE(dtantsur): WSGI containers may need to override the passed argv. +def initialize_wsgi_app(argv=sys.argv): i18n.install('ironic') - service.prepare_service(sys.argv) + service.prepare_service(argv) LOG.debug("Configuration:") CONF.log_opt_values(LOG, log.DEBUG) diff --git a/releasenotes/notes/any-wsgi-8d6ccb0590104146.yaml b/releasenotes/notes/any-wsgi-8d6ccb0590104146.yaml new file mode 100644 index 0000000000..d25447b01b --- /dev/null +++ b/releasenotes/notes/any-wsgi-8d6ccb0590104146.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Makes ``ironic.api.wsgi`` compatible with WSGI containers that cannot use + an executable WSGI entry point. For example, with gunicorn:: + + gunicorn -b 0.0.0.0:6385 'ironic.api.wsgi:initialize_wsgi_app(argv=[])'