0

Can I modify montrc so that it will not restart process immediately. The process has to be down for a full cycle before a restart is triggered. This is so I can keep my existing capistrano deploys.

3 Answers 3

2

you can use something like :

check process x with pidfile /var/run/x.pid
   every y cycles

or

start program = "/etc/init.d/x start" with timeout 90 seconds
1
  • I'm not sure about your 2nd option: here's the Monit doc about with timeout: In the case of a process check, Monit will wait up to 30 seconds for the start/stop action to finish before giving up and report an error. You can override this timeout using the TIMEOUT option or globally using the set limits. I think this is the allowed time to start, not the interval between stop and the next start. Jun 21, 2017 at 14:28
1

I do not think it is currently possible to do that if you're monitoring only the PID file. If however, you are also monitoring the service by listening in on a port, you can add a if failed port 8080 X times within Y cycles then restart clause. Monit will then curl that port every cycle, and when the count of failures reaches X across Y cycles, it will attempt to restart the service.

Keep in mind that this only affects the port monitor. If monit notices the PID file is gone, it will immediately try to restart it.

1
  • You could 'monitor' a fake PID file though. Aug 18, 2013 at 12:18
0

Try

check process x with pidfile /var/run/x.pid
  if does not exist for 2 cycles then start

This will wait a minimum of 1 full cycle before restarting the dead process.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.