-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gunicorn.conf.py
34 lines (29 loc) · 978 Bytes
/
gunicorn.conf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import json
import multiprocessing
from bothub_nlp_api import settings
default_web_concurrency = (
settings.BOTHUB_NLP_API_WORKERS_PER_CORE * multiprocessing.cpu_count()
)
if settings.BOTHUB_NLP_API_WEB_CONCURRENCY:
web_concurrency = int(settings.BOTHUB_NLP_API_WEB_CONCURRENCY)
assert web_concurrency > 0
else:
web_concurrency = max(int(default_web_concurrency), 2)
# Gunicorn config variables
loglevel = settings.BOTHUB_NLP_API_LOG_LEVEL
workers = web_concurrency
bind = f"{settings.BOTHUB_NLP_API_HOST}:{settings.BOTHUB_NLP_API_PORT}"
keepalive = settings.BOTHUB_NLP_API_KEEPALIVE
errorlog = "-"
# For debugging and testing
log_data = {
"loglevel": loglevel,
"workers": workers,
"bind": bind,
"keepalive": keepalive,
# Additional, non-gunicorn variables
"workers_per_core": settings.BOTHUB_NLP_API_WORKERS_PER_CORE,
"host": settings.BOTHUB_NLP_API_HOST,
"port": settings.BOTHUB_NLP_API_PORT,
}
print(json.dumps(log_data))