简体   繁体   中英

Monit / restart service when failed

I have a service, which is a server which listening to port: 7000.

I want to verify that the service is always up, and when it fails I want to start it again.

I wrote the next script in /etc/monit.d/myserver

check process myserver with pidfile /var/run/myserver.pid
    start program = "/etc/init.d/myserver start" with timeout 5 seconds
    stop program  = "/etc/init.d/myserver stop" with timeout 5 seconds
    if failed host 127.0.0.1 port 7000
        protocol HTTP request /testcheck then restart
    if 5 restarts within 5 cycles then timeout

But I notice that even when the process is running, it restart the service, and give the next information on the log:

EST Dec 18 03:05:13] error    : HTTP: error receiving data -- Resource temporarily unavailable
[EST Dec 18 03:05:13] error    : 'myserver ' failed protocol test [HTTP] at INET[127.0.0.1:7000] via TCP
[EST Dec 18 03:05:13] info     : 'myserver ' trying to restart
[EST Dec 18 03:05:13] info     : 'myserver ' stop: /etc/init.d/myserver 
[EST Dec 18 03:05:14] info     : 'myserver ' start: /etc/init.d/myserver 

How can I check it correctly so just when the service is down, it will restart it?

我遇到了同样的问题,最后我发现我没有正确运行monit守护进程,请看一下这篇文章: 如果进程停止,请在Monit中重新运行进程

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM