1

我正在尝试监视我的服务器,并且只想在它关闭时重新启动它。以下是我的监控

check process myserver with pidfile "/home/path/to/myserver.pid"
start program = "/etc/init.d/myserver start"
stop program = "/etc/init.d/myserver stop"
if failed host 127.0.0.1 port 8080 protocol http
then restart

但即使服务器正在运行 monit 也会出现如下错误:

'myserver' process not running
trying to restart 'myserver'
failed to restart myserver.

我该如何解决?我犯了一些错误吗?

此外,当我尝试使用“发送”和“期望”时,它会出现类似错误

Erro: syntax error 'send'.
4

1 回答 1

2

您可能需要指定 UID 和 GID,因为 monit 以 root 身份运行。

check process myserver 
  with pidfile "/home/path/to/myserver.pid"
  start program = "/etc/init.d/myserver start"
    as uid myserver_uid and gid myserver_gid
  stop program = "/etc/init.d/myserver stop"
    as uid myserver_uid and gid myserver_gid
if failed host 127.0.0.1 port 8080 protocol http
then restart

要调试,您可以尝试输出到文件并检查此文件以获取更多详细信息。

check process myserver 
  with pidfile "/home/path/to/myserver.pid"
  start program = "/etc/init.d/myserver start >> /tmp/myserver.log 2>&1"
    as uid myserver_uid and gid myserver_gid
  stop program = "/etc/init.d/myserver stop  >> /tmp/myserver.log 2>&1"
    as uid myserver_uid and gid myserver_gid
if failed host 127.0.0.1 port 8080 protocol http
then restart

对于发送和期望,您可能不需要它来进行 http 查询,因为支持 http 协议。

于 2013-09-26T17:10:58.540 回答