supervisor为例
开机自启
ubuntu
ubuntu开机自启有多种方式,你随意。编辑/etc/rc.local文件,
vi /etc/rc.local
在exit 0 之前加入以下命令
/usr/local/bin/supervisord
保存并退出。
最后修改rc.local权限
chmod +x /etc/rc.local
centos
新建文件supervisord.service
supervisord.service
[Unit]
Description=Supervisor daemon
[Service]
Type=forking
ExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.conf
ExecStop=/usr/bin/supervisorctl shutdown
ExecReload=/usr/bin/supervisorctl reload
KillMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
将文件拷贝到/usr/lib/systemd/system/
cp supervisord.service /usr/lib/systemd/system/
启动服务
systemctl enable supervisord
验证一下是否为开机启动
systemctl is-enabled supervisord
#!/bin/bash
# 开机启动supervisor
sleep 20
supervisord -c /etc/supervisor/supervisord.conf
sleep 15
kill -9 $(ps -e|grep supervisord | awk '{print $1}')
sleep 5
kill -9 $(ps -e|grep java | awk '{print $1}')
sleep 10
supervisord -c /etc/supervisor/supervisord.conf