安装
pip install supervisor
生成配置文件
echo_supervisord_conf > /home/stat/venv/web/etc/supervisord.conf
配置gunicorn的运行程序
[program:myapp]command=/home/stat/venv/web/bin/gunicorn -w4 -b0.0.0.0:2170 myapp:appdirectory=/path/myprojectautorestart=true
常用命令
指定配置文件则加上 -c supervisord.conf
# 通过配置文件启动supervisorsupervisord# 察看supervisor的状态supervisorctl status# 重新载入配置文件supervisorctl reload# 启动指定/所有supervisor管理的程序进程supervisorctl start [all]|[appname]# 关闭指定/所有 supervisor管理的程序进程supervisorctl stop [all]|[appname]
web管理界面(需要激活)
[inet_http_server] ; inet (TCP) server disabled by defaultport=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 socketserverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socketusername=user ; should be same as http_username if setpassword=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