为什么monit不重启服务器

Why is monit not restarting the server

我在一台 Ubuntu 机器上配置了 monit,配置如下:

check process apache with pidfile /var/run/apache2/apache2.pid
  start program = "/etc/init.d/apache2 start" with timeout 60 seconds
  stop program  = "/etc/init.d/apache2 stop"
  if cpu > 80% for 5 cycles then restart
  if children > 250 then restart

但是没有用。服务器有时会离线,但似乎什么也没发生。

知道为什么它没有重新启动吗?

我不知道你所说的 "server has become offline on occasions" 是什么意思。因为这可能意味着 Apache 运行 所在的节点已关闭,也可能意味着 http://localhost:80/ 无法访问。

如果以后是这种情况,则将配置更改为

check process apache with pidfile /var/run/apache2/apache2.pid
  start program = "/etc/init.d/apache2 start" with timeout 60 seconds
  stop program  = "/etc/init.d/apache2 stop"
  if failed host 127.0.0.1 port 80 then restart
  if cpu > 80% for 5 cycles then restart
  if children > 250 then restart

可能有用。因为如果 Apache 的进程是 运行,您的配置将不会重新启动 Apache,但由于任何问题无法在 http://localhost:80/

访问