Skip to main content

Configure gunicorn completely via environment variables

Project description

gunicorn_environmentconfig

Configure gunicorn completely via environment variables.

gunicorn itself provides environment variable access to only some of its settings. This package closes the gap, and allows configuring all settings via the environment.

Usage

Put this into your config file (usually gunicorn.conf.py):

import gunicorn_environmentconfig
gunicorn_environmentconfig.apply(globals())

Set environment variables with the naming scheme gunicorn.{setting}, where setting is the name you'd use in the config file, for example:

env gunicorn.preload_app=true python -m gunicorn myapp

If you append __literal__ to the variable name, they are evaluated as Python literals, for example to make gunicorn use the already existing logging configuration (which might e.g. use a JSON formatter) and not set up its own formatters, use this:

gunicorn.logconfig_dict__literal__={'root': {}, 'loggers': {'gunicorn.error': {'propagate': True}}, 'handlers': {}, 'formatters': {}}

Special case: ini file

To help with transitioning, settings read from a paste.ini configuration file can be added to the environment (environment takes priority).

To use this, set the GUNICORN_INI_CONFIG environment variable to the filename and section name.

[app:main]
use = egg:myapp#main

my_app_setting = value1
gunicorn.preload_app = true
env GUNICORN_INI_CONFIG=paste.ini#app:main python -m gunicorn myapp

gunicorn_environmentconfig Changes

1.0.1 (2023-05-19)

  • ini: Export ini file settings into environment (ini)

1.0.0 (2023-05-17)

  • Initial release (initial)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gunicorn_environmentconfig-1.0.1.tar.gz (3.4 kB view hashes)

Uploaded Source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page