You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Environmental variables set through Gunicorn via the '-e' CLI flag or the 'raw_env' configuration setting are not available during application start up when the application uses the '--preload' flag.
An example program to demonstrate this (using Flask 0.10.1 and Gunicorn 18.0) is here:
$ gunicorn -b localhost:8000 --preload -e FOO=bar test:application
This is the bootstrap. FOO = None
2014-05-05 20:56:14 [2575] [INFO] Starting gunicorn 18.0
2014-05-05 20:56:14 [2575] [INFO] Listening at: http://127.0.0.1:8000 (2575)
2014-05-05 20:56:14 [2575] [INFO] Using worker: sync
2014-05-05 20:56:14 [2584] [INFO] Booting worker with pid: 2584
However, when the '--preload' flag isn't used the environmental variable is available during application start up.
$ gunicorn -b localhost:8000 -e FOO=bar test:application
2014-05-05 21:06:00 [18244] [INFO] Starting gunicorn 18.0
2014-05-05 21:06:00 [18244] [INFO] Listening at: http://127.0.0.1:8000 (18244)
2014-05-05 21:06:00 [18244] [INFO] Using worker: sync
2014-05-05 21:06:00 [18249] [INFO] Booting worker with pid: 18249
This is the bootstrap. FOO = bar
When visiting 'localhost:8000' in a browser in both cases, the value of the 'FOO' variable is 'bar'.
$ curl http://localhost:8000/
The is the worker. FOO = bar
Is it expected behavior that environmental variables are not available during application start up when using the --preload flag?
The text was updated successfully, but these errors were encountered:
tshlabs
changed the title
Environmental variables not available durring '--preload' application start up
Environmental variables not available during '--preload' application start up
May 6, 2014
Environmental variables set through Gunicorn via the '-e' CLI flag or the 'raw_env' configuration setting are not available during application start up when the application uses the '--preload' flag.
An example program to demonstrate this (using Flask 0.10.1 and Gunicorn 18.0) is here:
https://gist.github.com/tshlabs/eb59186648fd003bf28c
The output from this is the following:
However, when the '--preload' flag isn't used the environmental variable is available during application start up.
When visiting 'localhost:8000' in a browser in both cases, the value of the 'FOO' variable is 'bar'.
Is it expected behavior that environmental variables are not available during application start up when using the --preload flag?
The text was updated successfully, but these errors were encountered: