以Ubuntu为例子
第一步:
安装
apt-get install supervisor
centos 用 yum install
第二步:
配置
程序路径 /etc/init.d/supervisor
配置路径 /etc/supervisor/supervisord.conf
扩展路径 /etc/supervisor/conf.d/*.conf (一个进程对应一个conf ,)
以nginx为例:
[program:nginx]
directory= ;程序启动目录 启动nginx 不用写这个
command=/usr/local/nginx/sbin/nginx ;要执行的命令,即启动需要守护的进程
priority=1 ;优先级
numprocs=1 ;启动的进程数目
autostart=true ;supervisor启动的时候是否随着同时启动
autorestart=true ;当supervisor程序crash的时候,这个进程会自动重启(很重要)
第三部:
启动web管理
我们如果要开启服务模式管理页面,可以在/etc/supervisor/supervisord.conf添加如下配置:
[inet_http_server] ; inet (TCP) server disabled by default
port=*:9001 ; (ip_address:port specifier, *:port for all iface)
username=admin ; (default is no username (open server))
password=password ; (default is no password (open server))