-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgunicorn.conf.py
63 lines (55 loc) · 1.71 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
53
54
55
56
57
58
59
60
61
62
63
import math
import os
from humanfriendly import parse_timespan
from flask_psc_model import load_metadata
def _load_timeout():
"""Load the maximum timeout value from the `model.yaml` metadata file."""
metadata = load_metadata(__file__)
max_timeout = max(
map(lambda timeout_: math.ceil(parse_timespan(str(timeout_))), metadata.timeout.values())
)
return max_timeout
# server socket
bind = ':%s' % os.environ.get('PSC_MODEL_PORT', '80')
# timeout
timeout = _load_timeout()
# logging
logconfig_dict = dict( # setup gunicorn and flask_psc_model logging
version=1,
disable_existing_loggers=False,
root={"level": "INFO", "handlers": ["error_console"]},
loggers={
"gunicorn.error": {
"level": "INFO",
"handlers": ["error_console"],
"propagate": False,
"qualname": "gunicorn.error"
},
"gunicorn.access": {
"level": "INFO",
"handlers": ["error_console"],
"propagate": False,
"qualname": "gunicorn.access"
},
"flask_psc_model": {
"level": "INFO",
"handlers": ["error_console"],
"propagate": False,
"qualname": "flask_psc_model"
},
},
handlers={
"error_console": {
"class": "logging.StreamHandler",
"formatter": "generic",
"stream": "ext://sys.stderr"
},
},
formatters={
"generic": {
"format": "%(asctime)s [%(process)d] [%(levelname)s] [%(name)s] %(message)s",
"datefmt": "[%Y-%m-%d %H:%M:%S %z]",
"class": "logging.Formatter"
},
}
)