Linux

重新啟動崩潰程序的簡單方法?

  • August 6, 2020

我需要監視在我的網路伺服器上執行的幾個程序。出於某種原因,varnish 目前每天或兩天崩潰一次。我正在使用 monit 自動重啟清漆,但它不起作用。這是我的 Varnish 的 monit.conf 條目。

check process varnish with pidfile /var/run/varnish.pid
   start program = "/etc/init.d/varnish start" with timeout 60 seconds
   stop program = "/etc/init.d/varnish stop"
   if failed host <my server ip> port 80 protocol http
       and request "/blank.html" then restart
   if 3 restarts within 5 cycles then timeout
   group server

日誌文件顯示 varnish 停止執行後,之後嘗試的重新啟動都失敗了。然後最終 monit 停止監視清漆。

有人對我如何解決這個問題有建議嗎?或者更好的是,你能推薦其他簡單的方法來自動監控和重啟崩潰的程序嗎?謝謝!

我會查看 daemontools ( http://cr.yp.to/daemontools.html )。

Supervise 正是為此目的而建構的——啟動程序並監視它們,如果它們終止則立即重新啟動它們。

如果您需要做比簡單的“它是否仍在執行”檢查更複雜的事情,您仍然可以使用 monit,如果需要重新啟動程序,則通過監督來完成。

您還可以使用*/etc/inittab使用**respawn*操作重新啟動死程序。

請參閱http://aplawrence.com/Unixart/startup.html上的 inittab 部分

引用自:https://serverfault.com/questions/52976