supervisor使用要点

作用:对运行脚本的监控【采用fork/exec的方式,将可执行文件对应的进程作为supervisor的子进程进行管理】,失败自动重启脚本。

 

可以为某个脚本生成单独的配置文件

echo_supervisord_conf > /etc/supervisor/conf.d/****.conf

 

启动supervisor

supervisord -c /etc/supervisor/****.conf   /* 启动配置文件中的program */

 

查看有哪些supervisord

ps aux | grep supervisord

 

查看某个conf对应的supervisord状况

supervisorctl -c ****.conf status   /* 对配置文件中的各个program进行管理 */

 

更改/新增配置文件后,需要先reload+restart,才能生效!

supervisorctl -c ****.conf reload

supervisorctl -c ****.conf restart ***

 

######################################################################

生成supervisor配置文件:echo_supervisord_conf > /etc/supervisord.conf
启动supervisor服务【
主服务,要和各个进程的supervisor服务要区分开】:supervisord -c /etc/supervisord.conf

 

supervisor是C/S模型:supervisord对应server端,supervisorctl对应client端。
supervisorctl借助socket文件,采用XML_RPC和supervisord通信。
supervisord客户端的命令行工具:supervisorctl

 

3个命令行工具:
supervisortd:supervisor的守护进程服务(用于接收进程管理命令)
supervisorctl:客户端(用于和守护进程通信,发送管理进程的指令)
echo_supervisord_conf:生成初始配置文件程序

主配置文件:/etc/supervisord.conf,当"需要监控的进程"的配置文件单独配置时,注意[include]选项。

更改了supervisor配置文件,需要重启:supervisorctl reload

注意:Supervisor只能管理非daemon的进程,不能管理守护进程。

######################################################################

 

常见错误:

1)在启动supervisord时,发生

Error: Another program is already listening on a port that one of our HTTP servers is configured to use. Shut this program down first before starting

需要删除/tmp/目录下的supervisor.sock文件,即unlink supervisor.sock

个人理解:sock文件沟通linux进程间通信,supervisorctl通过该文件,实现本地连接supervisord。

sock文件错误,导致一系列问题,深入原因后续研究。

 

2)在supervisorctl -c **.conf status没有输出时,尝试先kill掉supervisor,再回到错误1)是否发生。

3)当发现脚本并未真正监控时(脚本kill掉,无法自动挂起),尝试supervisorctl -c **.conf reload 和restart。

 

若要用浏览器来管理,需要配置inet_http_server

 

参考链接:

https://blog.csdn.net/kkevinyang/article/details/80539940

https://blog.csdn.net/xyang81/article/details/51555473

 

-- over --

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值