Monit does not wait for stop program before calling start program

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Monit does not wait for stop program before calling start program

Shankar SM

Hi,

                I have the following use case, where I don’t want certain application to take more than a certain amount of memory. If it ever exceeds for any reason I want it to restart. So I have the following configuration in monitrc

 

Check process my-process matching ‘my-process’

  start program “/etc/init.d/S77-my-process start” with timeout 10 seconds

  stop program “/etc/init.d/K23-my-process stop”

  if memory usage > 12.0 MB for 4 cycles then restart

  if 5 restarts within 5 cycles then unmonitor

 

So when the memory exceeds the stated limit I see that the stop script is called but monit does not wait for the stop script to complete. Monit looks like just waits for the process it was monitoring (my-process) to be killed and once it detects that, it calls the start program.

I have few cleanup steps to do after the process has been killed before it can be started again (which happens in the stop script) however it is started before the cleanup is complete.

 

I tried changing the action as below to execute a script for restart however the last line, if 5 restarts within 5 cycles then unmonitor does not seem to work.

if memory usage > 12.0 MB for 4 cycles then exec “/etc/init.d/S77-my-process restart”

 

Do you guys have any suggestion for this use case?

 

Thanks

Shankar

 


--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general
Reply | Threaded
Open this post in threaded view
|

Re: Monit does not wait for stop program before calling start program

Lutz Mader
Hello Shankar,
the number of cycles is to low.

> if 5 restarts within 5 cycles then unmonitor

The rule match, if the process restart every cycle only. I use something
like

  if not exist for 5 cycles then start
  if 3 restarts within 50 cycles then unmonitor

to stop useless recovery (with unmonitor) and increase the "start" time
after services terminated.

A suggestion only,
Lutz


--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general