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
This commit is contained in:
Dmitry Tantsur 2020-01-24 12:19:05 +01:00
parent 443e0b1093
commit 4504bd5a8d
3 changed files with 27 additions and 2 deletions

View File

@ -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"])'

View File

@ -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)

View File

@ -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=[])'