forked from mouday/spider-admin-pro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgunicorn.conf.py
53 lines (35 loc) · 933 Bytes
/
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
# -*- coding: utf-8 -*-
"""
$ gunicorn --config gunicorn.conf.py spider_admin_pro.run:app
"""
import multiprocessing
import os
from gevent import monkey
monkey.patch_all()
# 日志文件夹
LOG_DIR = 'logs'
if not os.path.exists(LOG_DIR):
os.mkdir(LOG_DIR)
def resolve_file(filename):
return os.path.join(LOG_DIR, filename)
def get_workers():
return multiprocessing.cpu_count() * 2 + 1
# daemon = True
daemon = False # 使用supervisor不能是后台进程
# 进程名称
proc_name = "spider-admin-pro"
# 启动端口
bind = "127.0.0.1:5001"
# 日志文件
loglevel = 'debug'
pidfile = resolve_file("gunicorn.pid")
accesslog = resolve_file("access.log")
errorlog = resolve_file("error.log")
# 启动的进程数
# workers = get_workers()
workers = 2
worker_class = 'gevent'
# 启动时钩子
def on_starting(server):
ip, port = server.address[0]
print('server.address:', f'http://{ip}:{port}')