进程中断的时候Supervisor能自动重新启动
2024-10-16Supervisor(监督人),在Linux中Supervisor是一个进程管理工具,当进程中断的时候Supervisor能自动重新启动它。可以运行在各种类Linux/unix的机器上,supervisor是用Python开发的一套通用的进程管理程序,能将一个普通的命令行进程变为后台daemon,并监控进程状态,异常退出时能自动重启。
0、yum install epel-release
yum search supervisor
yum -y install supervisor
1、vi /etc/supervisord.conf
[include]
files = supervisord.d/*.ini
2、cat << EOF > /etc/supervisord.d/configSyncService.ini
[program:configSyncService]
directory = /jesong/cluster/configSyncService/
command = sh run.sh
autostart = true
startsecs = 15
autorestart = true
startretries = 3
user=root
redirect_stderr = true
stdout_logfile_maxbytes = 20MB
stdout_logfile_backups = 20
EOF
3、systemctl start supervisord
systemctl restart supervisord.service
4、systemctl status supervisord
5、检查一下
ps -ef|grep configSyncService|grep -v grep |awk '{print $2}'|xargs kill -9