Or Smith
Or Smith

Reputation: 3616

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?

Upvotes: 1

Views: 2623

Answers (1)

slashmili
slashmili

Reputation: 1220

I had the same problem and at the end I found out that I'm not running monit daemon properly take look at this post: Rerun a process in Monit if process stops

Upvotes: 2

Related Questions