forked from usnistgov/NEMO
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgunicorn_configuration.py
More file actions
17 lines (16 loc) · 1.03 KB
/
gunicorn_configuration.py
File metadata and controls
17 lines (16 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# This is the default Gunicorn configuration file for the NEMO Docker image.
# It is mounted inside the image at /etc/gunicorn_configuration.py, and you can override it by
# mounting your own configuration file to this location or providing command line arguments to Gunicorn.
import os
from multiprocessing import cpu_count
bind = "0.0.0.0:8000"
preload_app = True
worker_class = os.getenv("GUNICORN_WORKER_CLASS", "gthread") or "gthread"
# The following value was decided based on the Gunicorn documentation and configuration example:
# http://docs.gunicorn.org/en/stable/configure.html#configuration-file
workers = int(os.getenv("GUNICORN_WORKER_COUNT", min(cpu_count() * 2 + 1, 9)) or min(cpu_count() * 2 + 1, 9))
threads = int(os.getenv("GUNICORN_THREAD_COUNT", "8") or "8")
keepalive = int(os.getenv("GUNICORN_KEEPALIVE_SECONDS", "300") or "300")
capture_output = (os.getenv("GUNICORN_CAPTURE_OUTPUT", "True") or "True") == "True"
if os.getenv("GUNICORN_SCRIPT_NAME"):
os.environ.setdefault("SCRIPT_NAME", os.getenv("GUNICORN_SCRIPT_NAME"))