重新启动崩溃进程的简单方法?

Lin*_*Lin 11 linux monitoring web-server varnish monit

我需要监控在我的网络服务器上运行的几个进程。出于某种原因,清漆目前每天或每两天崩溃一次。我正在使用 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
Run Code Online (Sandbox Code Playgroud)

日志文件显示,在varnish停止运行后,尝试重新启动之后都失败了。然后最终 monit 停止监视清漆。

有人对我如何解决这个问题有建议吗?或者更好的是,您能否提出其他简单的自动监控和重启崩溃进程的方法?谢谢!

Ian*_*and 17

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

Supervise 正是为此目的而构建的——启动进程并监视它们,如果它们终止就立即重新启动它们。

如果您需要做比简单的“是否仍在运行”检查更复杂的事情,您仍然可以使用 monit,并且如果需要重新启动进程,则通过监督来完成。