forked from Dorado607/WebSearchAIO
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgunicorn_config_hyr-dev.py
54 lines (49 loc) · 1.58 KB
/
gunicorn_config_hyr-dev.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
import multiprocessing
import os
from datetime import datetime
# 监听内网端口
bind = '0.0.0.0:7872'
# 工作目录
chdir = './'
# 并行工作进程数
# workers = multiprocessing.cpu_count()
workers = 2
# 指定每个工作者的线程数
threads = 4
# 监听队列
backlog = 512
# 超时时间
timeout = 120
# 设置守护进程,将进程交给 supervisor 管理;如果设置为 True 时,supervisor 启动日志为:
# gave up: fastapi_server entered FATAL state, too many start retries too quickly
# 则需要将此改为: False
daemon = False
# 工作模式协程
worker_class = 'uvicorn.workers.UvicornWorker'
# 设置最大并发量
worker_connections = 100
# 设置进程文件目录
pid_dir = "./flagged"
if not os.path.exists(pid_dir):
os.makedirs(pid_dir)
pidfile = './flagged/gunicorn.pid'
log_dir = "./logs"
if not os.path.exists(log_dir):
os.makedirs(log_dir)
# 设置访问日志和错误信息日志路径
accesslog = './logs/websearchaio_access_{}.log'.format(datetime.now().strftime('%Y-%m-%d_%H'))
errorlog = './logs/websearchaio_error_{}.log'.format(datetime.now().strftime('%Y-%m-%d_%H'))
# 如果supervisor管理gunicorn
# errorlog = '-'
# accesslog = '-'
# 设置gunicron访问日志格式,错误日志无法设置
access_log_format = '%(t)s %(p)s %(h)s "%(r)s" %(s)s %(L)s %(b)s %(f)s" "%(a)s"'
# 设置这个值为true 才会把打印信息记录到错误日志里
capture_output = True
# 设置日志记录水平
loglevel = 'debug'
# python程序
# pythonpath = ''
# 启动 gunicorn -c gunicorn.py api:app
# 查看进程树 pstree -ap|grep gunicorn
# 终止 kill -9 (pid)