环境:CentOS Linux release 7.4
pip install supervisor
#加载配置,修改如下
echo_supervisord_conf > /etc/supervisord.conf
mkdir /etc/supervisord.d/
vi /etc/supervisord.conf
[include]
files = /etc/supervisord.d/*.ini
#start service
supervisord -c /etc/supervisord.conf
#write a program config
vi /etc/supervisord.d/SimpleHttp.ini
[program:SimpleHttp]
command=python2 -m SimpleHTTPServer 9000
directory=/root ;执行command之前,先切换到工作目录
user=root ;使用oxygen用户来启动该进程
autorestart=true ;程序崩溃时自动重启,重启次数是有限制的,默认为3次
stdout_logfile = /tmp/simple_http.log
loglevel=info
#roload program config, start service
supervisorctl update //配置文件修改后使用该命令加载新的配置
supervisorctl status
#配置服务报警
pip install superlance
#Supervisor 事件发送到飞书
cp feishu-alert/event.conf /etc/supervisord.d/event.ini
supervisorctl update
注意:
1. 更给任何脚本时需执行以下命令,否则更改不生效
supervisorctl reload
参考:
https://www.jianshu.com/p/0b9054b33db3
https://cloud.tencent.com/developer/article/1414822
https://github.com/cmboss/supervisor-event-to-dingtalk-alert