supervisord
负责管理进程的server端,配置文件是/etc/supervisor/supervisord.conf
supervisorctl
client端的命令行工具,管理子进程,配置文件在/etc/supervisor/supervisord.d/目录下
yum install -y supervisor
安装supervisor
systemctl enable supervisord
开机自启
systemctl start supervisord
启动supervisord
systemctl status supervisord
查看状态
vim /etc/supervisord.conf
修改配置文件
开启web界面访问
把[inet_http_server]模块的注释去掉
并修改IP、用户名与密码
[inet_http_server]
port=192.168.1.108:9001
username=root
password=123456
supervisorctl reload
重新加载配置文件
访问
http://192.168.1.108:9001
cat /etc/supervisord.conf
查看配置文件最后一个模块
配置需要管理的进程
也可修改为
files = supervisord.d/*.conf后缀
目录在/etc/supervisord.d/下面
vim itchat.ini
新增itchat进程
[program:itchat]
directory = /var/www/itchat/application ;启动目录
command = python3 scwechat.py ;启动命令
autostart = true ;在supervisord启动的时候也启动
startsecs = 5 ;启动5秒后没有异常退出,就当作已经正常启动了
autorestart = true ;程序异常退出后自动重启
startretries = 3 ;启动失败自动重试次数,默认是3
user = root ;哪个用户启动
redirect_stderr = true ;把stderr重定向到stdout,默认false
stdout_logfile_maxbytes = 20MB ;stdout日志文件大小,默认50MB
stdout_logfile_backups = 20 ;stdout日志文件备份数
stdout_logfile = /tmp/supervisord/itchat.log
;stdout日志文件,需要手动创建/tmp/supervisord目录
supervisorctl start itchat
启动itchat进程
如果报错
FATAL can't find command 'python3'
则填写java的绝对路径
command = /usr/local/python3/bin/python3.7 scwechat.py
vim community.ini
新增community进程
[program:community]
directory = /var/www/html/jhj.dev.mall.fincgo.com/tools/cronjob/subscribe
command = php Community.php -start -p=6377
autostart = true
startsecs = 5
autorestart = true
startretries = 3
user = root
redirect_stderr = true
stdout_logfile_maxbytes = 20MB
stdout_logfile_backups = 20
stdout_logfile = /tmp/supervisord/community.log
supervisorctl start community
启动community进程
supervisorctl
> status #查看程序状态
> stop name #关闭name程序
> start name #启动name程序
> restart name # 重启name程序
> reread #读取有更新的配置文件,不会启动新添加的程序
> update #重启配置文件修改过的程序