From c82996f791a496e4c45fd7e9078047e46717acb2 Mon Sep 17 00:00:00 2001 From: Kevin Michel Date: Wed, 29 Jan 2020 17:01:27 +0100 Subject: [PATCH 1/3] Add documentation for the $PORT environment variable --- docs/source/settings.rst | 4 ++++ gunicorn/config.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/docs/source/settings.rst b/docs/source/settings.rst index 16d8961a..bf67bd25 100644 --- a/docs/source/settings.rst +++ b/docs/source/settings.rst @@ -1164,6 +1164,10 @@ Multiple addresses can be bound. ex.:: will bind the `test:app` application on localhost both on ipv6 and ipv4 interfaces. +If the ``PORT`` environment variable is defined, the default +is ``['0.0.0.0:$PORT']``. If it is not defined, the default +is ``['127.0.0.1:8000']``. + .. _backlog: backlog diff --git a/gunicorn/config.py b/gunicorn/config.py index 6c1d1777..d501db69 100644 --- a/gunicorn/config.py +++ b/gunicorn/config.py @@ -579,6 +579,10 @@ class Bind(Setting): will bind the `test:app` application on localhost both on ipv6 and ipv4 interfaces. + + If the ``PORT`` environment variable is defined, the default + is ``['0.0.0.0:$PORT']``. If it is not defined, the default + is ``['127.0.0.1:8000']``. """ From a648f8a838c1b5b1dd45cbd2b8bc849296ebf48a Mon Sep 17 00:00:00 2001 From: Kevin Michel Date: Wed, 29 Jan 2020 17:03:24 +0100 Subject: [PATCH 2/3] Document how environment variables impact configuration --- docs/source/configure.rst | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/docs/source/configure.rst b/docs/source/configure.rst index df5cbe2e..370f7070 100644 --- a/docs/source/configure.rst +++ b/docs/source/configure.rst @@ -4,23 +4,35 @@ Configuration Overview ====================== -Gunicorn pulls configuration information from three distinct places. +Gunicorn reads configuration information from five places. -The first place that Gunicorn will read configuration from is the framework +Gunicorn first reads environment variables for some +configuration :ref:`settings `. + +Gunicorn will then read configuration from a framework specific configuration file. Currently this only affects Paster applications. -The second source of configuration information is a configuration file that is -optionally specified on the command line. Anything specified in the Gunicorn -config file will override any framework specific settings. +The third source of configuration information is a configuration file that is +optionally specified using command line arguments. Anything specified in the +Gunicorn config file will override any framework specific settings. + +The fourth place of configuration information are command line arguments +stored in an environment variable named ``GUNICORN_CMD_ARGS``. Lastly, the command line arguments used to invoke Gunicorn are the final place considered for configuration settings. If an option is specified on the command line, this is the value that will be used. +When a configuration file is specified in the command line arguments and in the +``GUNICORN_CMD_ARGS`` environment variable, only the configuration +file specified on the command line is used. + Once again, in order of least to most authoritative: - 1. Framework Settings - 2. Configuration File - 3. Command Line + 1. Environment Variables + 2. Framework Settings + 3. Configuration File + 4. ``GUNICORN_CMD_ARGS`` + 5. Command Line .. note:: From 83b78e09c10c2f7a07eed5300104cc09a4f4cbf4 Mon Sep 17 00:00:00 2001 From: Kevin Michel Date: Fri, 31 Jan 2020 09:47:06 +0100 Subject: [PATCH 3/3] Document the default name and path for the configuration file --- docs/source/configure.rst | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/source/configure.rst b/docs/source/configure.rst index 370f7070..c340f5ee 100644 --- a/docs/source/configure.rst +++ b/docs/source/configure.rst @@ -6,15 +6,16 @@ Configuration Overview Gunicorn reads configuration information from five places. -Gunicorn first reads environment variables for some -configuration :ref:`settings `. +Gunicorn first reads environment variables for some configuration +:ref:`settings `. -Gunicorn will then read configuration from a framework -specific configuration file. Currently this only affects Paster applications. +Gunicorn then reads configuration from a framework specific configuration +file. Currently this only affects Paster applications. -The third source of configuration information is a configuration file that is -optionally specified using command line arguments. Anything specified in the -Gunicorn config file will override any framework specific settings. +The third source of configuration information is an optional configuration file +``gunicorn.conf.py`` searched in the current working directory or specified +using a command line argument. Anything specified in this configuration file +will override any framework specific settings. The fourth place of configuration information are command line arguments stored in an environment variable named ``GUNICORN_CMD_ARGS``.