Supervisor 安装、配置及用法
前言
Supervisor is a client/server system that allows its users to control a number of processes on UNIX-like operating systems.
安装
1 | $ pip3 install supervisor |
卸载
1 | $ pip3 uninstall supervisor |
配置
gunicorn.conf.py
文件1
2
3
4
5
6
7
8
9
10
11
12
13
14import multiprocessing
bind = '127.0.0.1:9046'
workers = multiprocessing.cpu_count() * 2 + 1
threads = 2
backlog = 512
daemon = True #True守护进程启动
chdir = '/Users/guohaitao/Desktop/py/project/circle'
access_log_format = '%(h)s %(l)s %(u)s %(t)s %(s)s %(b)s'
loglevel = 'info'
worker_class = 'sync'
errorlog = chdir + '/logs/error.log'
accesslog = chdir + '/logs/access.log'
pidfile = chdir + '/logs/pidfile.pid'
启动:1
2
3./venv/bin/gunicorn -c gunicorn.conf.py myapp:app
或
gunicorn -c gunicorn.conf.py myapp:app
若没有上述配置文件,我们可以通过参数方式进行配置启动:1
gunicorn -w 2 -b 127.0.0.1:9045 myapp:app # 指定线程数,指定端口
关闭1
kill `cat logs/pidfile.pid`
参考资料
文档信息
- 版权声明:自由转载-保持署名-非商用-非衍生 ( CC BY-NC-ND 4.0 )