-
Notifications
You must be signed in to change notification settings - Fork 0
/
gunicorn.conf.py
52 lines (41 loc) · 1.33 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import logging
import cdislogging
import gunicorn.glogging
import gen3discoveryai.config
class CDISLogger(gunicorn.glogging.Logger):
"""
Initialize root and gunicorn loggers with cdislogging configuration.
"""
@staticmethod
def _remove_handlers(logger):
"""
Use Python's built-in logging module to remove all handlers associated
with logger (logging.Logger).
"""
while logger.handlers:
logger.removeHandler(logger.handlers[0])
def __init__(self, cfg):
"""
Apply cdislogging configuration after gunicorn has set up it's loggers.
"""
super().__init__(cfg)
self._remove_handlers(logging.getLogger())
cdislogging.get_logger(
None, log_level="debug" if gen3discoveryai.config.DEBUG else "warn"
)
for logger_name in ["gunicorn", "gunicorn.error", "gunicorn.access"]:
self._remove_handlers(logging.getLogger(logger_name))
cdislogging.get_logger(
logger_name,
log_level="debug" if gen3discoveryai.config.DEBUG else "info",
)
logger_class = CDISLogger
wsgi_app = "gen3discoveryai.main:app"
bind = "0.0.0.0:8089"
workers = 1
user = "appuser"
group = "appuser"
# OpenAI API can take a while
# default was `30`
timeout = 300
graceful_timeout = 300