[Top][All Lists]

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

Re: apache restart while rotating logs

From: Martin Pala
Subject: Re: apache restart while rotating logs
Date: Sat, 05 Mar 2005 20:34:20 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20050105 Debian/1.7.5-1


it should be sufficient to use 'apachectl graceful' in logrotate instead of restart.

Using 'graceful' (SIGUSR1) the apache master process keeps running with the same PID and just reloads the configuration, check files and gracefully restarts workers (waiting for their work to finish).


Charles Fry wrote:

First of all, let me express my appreciation for monit. It took me a while to find it, but I have much enjoyed it.

My current problem is that monit regularly restarts apache while my logs are being rotated. I am running a Debian system installed on a low-memory UML server. My monitrc contains essentially the following recipe:

check process apache2 with pidfile /var/run/
    start program = "/etc/init.d/apache2 start"
    stop  program = "/etc/init.d/apache2 stop"

As far as I can tell, this happens because /etc/logrotate.d/apache2 calls "/etc/init.d/apache2 restart"" which executes the following:

    echo -n "Forcing reload of web server: Apache2"
    sleep 10
    $APACHE2CTL startssl
    echo "."

During those 10 sleep seconds, monit notices the missing pid and impatiently restarts apache, even though the init script is also in the process of restarting apache. Obviously this inevitably leads to errors, in addition to a wasteful restart of apache, which is already restarting.

I was hoping that there would be a way to tell monit "wait for x seconds and then if you still can't find the pid file, restart this process." I see the syntax for doing this in the case of failed connections, but not for missing pids.

I realize that I could also modify my logrotate script to execute "monit restart apache2" when rotating my logs. The problem with this is that it does not insert the 10 second wait between the start and stop, as the init.d restart does, so apache hasn't finished shutting down when the start is attempted, and the start fails. This thus puts me in a worse situation than before, as I must wait for monit's next polling cycle before the failed apache (brought down by monit) is found and restarted.

Any assistance would be appreciated.


Is he
Or just blind--
This guy who drives
So close behind?

To unsubscribe:

reply via email to

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