-
Notifications
You must be signed in to change notification settings - Fork 0
/
gunicorn.conf
42 lines (31 loc) · 1.28 KB
/
gunicorn.conf
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
# gunicorn.conf
import logging
import multiprocessing
from logging.handlers import TimedRotatingFileHandler
from gunicorn.glogging import Logger
filepath = "/data/zgx/test/test/flaskTest/list_embedding/log/"
th_acc = TimedRotatingFileHandler(when="S", backupCount=7, filename=filepath + "access.log")
th_err = TimedRotatingFileHandler(when="S", backupCount=7, filename=filepath + "error.log")
th_acc.setFormatter(logging.Formatter("[%(asctime)s] %(levelname)s | %(message)s"))
th_err.setFormatter(logging.Formatter("[%(asctime)s] %(levelname)s | %(message)s"))
# gunicorn源码中不支持按日切分日志
class SplitLogger(Logger):
def __init__(self, cfg):
super(SplitLogger, self).__init__(cfg)
self.access_log.addHandler(th_acc)
self.error_log.addHandler(th_err)
# Server Socket
bind = ["0.0.0.0:8000"]
backlog = 512
chdir = "/var/log/gunicorn/"
timeout = 100
# Worker Processes
worker_class = "gevent"
workers = multiprocessing.cpu_count() * 2 + 1
# Logging
loglevel = "info"
access_log_format = '%(t)s %(p)s %(h)s "%(r)s" %(s)s %(L)s %(b)s %(f)s" "%(a)s"'
accesslog = "/var/log/gunicorn/gunicorn_access.log"
error_log_format = '%(t)s %(p)s %(h)s "%(r)s" %(s)s %(L)s %(b)s %(f)s" "%(a)s"'
errorlog = "/var/log/gunicorn/gunicorn_error.log"
logger_class = SplitLogger