- 安装supervisor
#安装 supervisor
yum install supervisor
- 增加可读权限
sudo chmod 777 /run
- 添加要监控程序的配置文件
在/etc/supervisord.d下添加,例如abc.ini
[program:abc]
command=python3 /usr/pyProject/abc/main.py
directory=/usr/pyProject/abc
user=root
stopsignal=INT
autostart=true
autorestart=true
startsecs=3
stderr_logfile=/usr/pyProject/abc/LOG/abc.err.log
stdout_logfile=/usr/pyProject/abc/LOG/abc.out.log
- 启动服务
通常先stop一下服务,注意:这个命令是CentOS7.6的,不适用CentOS6
systemctl stop supervisord.service
systemctl start supervisord.service
然后再开启相应的守护
supervisorctl start all