start-stop-daemon自动重启

在Debian系统内碰到使用start-stop-daemon但是start-stop-daemon本身并不支持程序挂掉后自动重启,但是可以使用Debian自有的service机制达成自动重启的效果

在/etc/systemd/system/下新增服务说明文件xxx.service,如下

[Service]
ExecStart=/etc/init.d/xxx restart
Restart=always
RestartSec=1
Type=forking
PIDFile=/run/xxx.pid

/etc/init.d/xxx 文件就是使用start-stop-daemon启动程序的脚本,支持restart参数

在需要启动时使用systemctl restart xxx.service,就可以实现程序挂掉后自动重启