|
From: | Shankar SM |
Subject: | Monit does not wait for stop program before calling start program |
Date: | Mon, 15 May 2017 19:20:06 +0000 |
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 |
[Prev in Thread] | Current Thread | [Next in Thread] |