[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can monit block/wait on start/stop exec at all? (Chris McKenzie

From: Jan-Henrik Haukeland
Subject: Re: Can monit block/wait on start/stop exec at all? (Chris McKenzie
Date: Thu, 17 May 2007 23:05:07 +0200

On 17. mai. 2007, at 19.38, Chris McKenzie wrote:

I want to know if I can get monit to wait for the program exec

On stop and restart, monit will in fact wait for the program to stop (see control.c and the function do_stop). On restart, monit waits until the program is stopped before it starts the program again. The way monit does this is first to call the process stop program and then go into a loop and check if either the pid in the pid file is gone or if the pid file itself is gone. If this is the case it goes on to call the start program again otherwise an alert error is raised.

There will be a problem if the program to be stopped removes its pid file before it is actually stopped. Normally one of the last thing a daemon program should do is to remove its pid file. If it does this earlier in the shutdown process there is going to be a problem since monit then will assume that the process is gone (because the pid file is gone) and continue and call the start program.

Looking at the monit code now I can see that this can be improved by caching the pid before calling stop and instead of testing for the existence of both the pid file and process id only test for the process id. I'll see if I can hack a solution and I'll let you know when it can be tested.

Best regards
Jan-Henrik Haukeland

reply via email to

[Prev in Thread] Current Thread [Next in Thread]