-
Notifications
You must be signed in to change notification settings - Fork 0
/
gunicorn.conf.py
51 lines (39 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
import logging
import cdislogging
import gunicorn.glogging
# do not overwrite gunicorn's `config`
from gen3workflow.config import config as app_config
class CustomLogger(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 app_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 app_config["DEBUG"] else "info",
)
logger_class = CustomLogger
wsgi_app = "gen3workflow.app:app"
bind = "0.0.0.0:8000"
workers = 2
# default was `30` for the 2 below
timeout = 90
graceful_timeout = 90