Monit不重启进程

我有monit一个进程,但它并没有意识到它是失败的。 我的监视configuration是这样的:

  check process xxx with pidfile /var/run/xxx.pid group yyy start program = "/etc/init.d/xxx start" stop program = "/etc/init.d/xxx stop" if failed host 127.0.0.1 port 9999 then restart if 5 restarts within 5 cycles then timeout 

问题是即使我的进程已经崩溃,PID文件仍然存在。 所以… PID存在,但本地主机端口9999应该失败。 所以…是否期望monit不重新启动这个过程? 应该删除pid文件吗? 不能做那样的OR

提前致谢,

纠正我,如果我错了:

  • 如果程序崩溃,PID文件停留,但端口9999closures
  • 如果程序停止干净,PID文件被删除,端口9999被closures

常见的行为是关于端口9999的。你可以用这样的东西来监视它:

 check host 127.0.0.1 with address 127.0.0.1 start program = "/etc/init.d/xxx restart" stop program = "/etc/init.d/xxx stop" if failed port 9999 then restart 

上面的内容应该足以涵盖所有的情况,但是你可以把它作为一个附加的陈述添加到你现有的陈述中(这将是你正在谈论的那种)。

看看有关检查主机的文档 。

PS:我认为, 关于文档(关于Apache的示例) ,即使PID文件仍然存在,如果端口9999不可访问,您拥有的configuration应该能够重新启动您的进程。 我的猜测是端口9999没有closures,或者端口9999没有在127.0.0.1(请使用netstat检查所有这些)。

所以,在你的configuration中,尝试用这个replace端口监视器行:

if failed port 9999 then restart (删除host 127.0.0.1 )。