|
| 1 | +# https://github.com/tiangolo/uvicorn-gunicorn-docker/blob/master/docker-images/gunicorn_conf.py |
| 2 | +import json |
| 3 | +import os |
| 4 | + |
| 5 | +accesslog_var = os.getenv("ACCESS_LOG", "-") |
| 6 | +use_accesslog = accesslog_var or None |
| 7 | +errorlog_var = os.getenv("ERROR_LOG", "-") |
| 8 | +use_errorlog = errorlog_var or None |
| 9 | +graceful_timeout_str = os.getenv("GRACEFUL_TIMEOUT", "120") |
| 10 | +timeout_str = os.getenv("TIMEOUT", "120") |
| 11 | +keepalive_str = os.getenv("KEEP_ALIVE", "5") |
| 12 | + |
| 13 | +# Gunicorn config variables |
| 14 | +loglevel = os.getenv("LOG_LEVEL", "info") |
| 15 | +workers = 1 |
| 16 | +bind = os.getenv("BIND", "0.0.0.0:5678") |
| 17 | +errorlog = use_errorlog |
| 18 | +worker_tmp_dir = "/dev/shm" |
| 19 | +accesslog = use_accesslog |
| 20 | +graceful_timeout = int(graceful_timeout_str) |
| 21 | +timeout = int(timeout_str) |
| 22 | +keepalive = int(keepalive_str) |
| 23 | +forwarded_allow_ips = '*' |
| 24 | + |
| 25 | +# For debugging and testing |
| 26 | +log_data = { |
| 27 | + "loglevel": loglevel, |
| 28 | + "workers": workers, |
| 29 | + "bind": bind, |
| 30 | + "graceful_timeout": graceful_timeout, |
| 31 | + "timeout": timeout, |
| 32 | + "keepalive": keepalive, |
| 33 | + "errorlog": errorlog, |
| 34 | + "accesslog": accesslog, |
| 35 | + "forwarded_allow_ips": forwarded_allow_ips, |
| 36 | +} |
| 37 | +print(json.dumps(log_data)) |
0 commit comments