[Top][All Lists]

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

Re: restart program

From: David Fletcher
Subject: Re: restart program
Date: Tue, 18 Apr 2006 19:39:39 +0100

Hi Mike,

I have a similar issue with stopping MySQL, and perhaps a more general
solution idea. I'll describe the problem, and then a possible solution.

Once a night on the backup version of a webserver I run, a script copies
across the most recent version of the database files from the main server. (I
know there are other replication approaches, but that is how it's working
now). The script uses

monit stop mysql

but this returns instantly, even though MySQL takes a little time to close
down fully. I have written a check into the script to ensure that MySQL has
really closed down before copying the files into the data directory. If the
files are written while the database is still running they will be corrupted.

Perhaps a command of the form

monit stop_fully mysql

which only returned after mysql has really stopped would be useful for this
and other services such as Apache. A timeout (perhaps with a different return
value?) would be needed to prevent lockup cases, and to alert any script that
monit had been unable to stop the service.

I suppose the internal logic would be something like

monit stop service
time = 0
while (pid file still present && time < 30){
    sleep 2
    time +=2
if (time >= 30)
    return error
    return stopped_ok



> From: "Mike Jackson" <address@hidden>
> Subject: restart program
> To: <address@hidden>
> Message-ID: <address@hidden>
> Content-Type: text/plain; format=flowed; charset="Windows-1252";
>       reply-type=original
> Would it be possible to add a "restart program" configuration option to 
> Monit, in addition to the "stop program" and "start program" options? The 
> reason I ask: Occasionally, if Monit needs to restart Apache, it will issue 
> the stop command. apachectl will return successfully almost right away, even

> if the processes aren't completely terminated and the ports freed. Monit 
> thinks it's ready to start it up, and issues the start command. Apache then 
> (to use a technical term) freaks out and sits there in limbo. It's not truly

> answering requests, but it also can't be restarted. My init.d script was set

> to sleep 5 seconds between the start and stop cycles if you issued the 
> restart command line option; I moved the sleep invocation to the stop cycle,

> but it would be nice if Monit could issue a different command when it needs 
> to restart, instead of running the stop command and then the start command. 

reply via email to

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