supervisor配置

安装

1
pip install supervisor

生成配置文件

1
echo_supervisord_conf > /home/stat/venv/web/etc/supervisord.conf

配置gunicorn的运行程序

1
2
3
4
[program:myapp]
command=/home/stat/venv/web/bin/gunicorn -w4 -b0.0.0.0:2170 myapp:app
directory=/path/myproject
autorestart=true

常用命令

指定配置文件则加上 -c supervisord.conf

1
2
3
4
5
6
7
8
9
10
# 通过配置文件启动supervisor
supervisord
# 察看supervisor的状态
supervisorctl status
# 重新载入配置文件
supervisorctl reload
# 启动指定/所有supervisor管理的程序进程
supervisorctl start [all]|[appname]
# 关闭指定/所有 supervisor管理的程序进程
supervisorctl stop [all]|[appname]

web管理界面(需要激活)

1
2
3
4
5
6
7
8
9
10
11
12
[inet_http_server]        ; inet (TCP) server disabled by default
port=127.0.0.1:9001 ; (ip_address:port specifier, *:port for all iface)
username=user ; (default is no username (open server))
password=123 ; (default is no password (open server))

[supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket
serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket
username=user ; should be same as http_username if set
password=123 ; should be same as http_password if set
;prompt=mysupervisor ; cmd line prompt (default "supervisor")
;history_file=~/.sc_history ; use readline history if available
文章目录
  1. 1. 安装
  2. 2. 生成配置文件
  3. 3. 配置gunicorn的运行程序
  4. 4. 常用命令
  5. 5. web管理界面(需要激活)