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