/etc/init.d/apache2 restart lags, fails with mpm_worker, SSL
If you've switched to the threaded mpm_worker you may have noticed restarting apache sometimes looks like this:
* Stopping apache2 ... [ ok ] * Starting apache2 ... * start-stop-daemon: /usr/sbin/apache2 is already running
Then, if you wait for it to really die, this:
# /etc/init.d/apache2 restart * apache2 not running (no pid file) * Starting apache2 ...
SSL vhosts add considerably to the amount of time it takes for apache to start or stop; I've had this problem crop up on a server that otherwise seemed fine until I added an SSL host which lead me down the wrong path.
The actual culprit is a bug in the init script:
https://bugs.gentoo.org/show_bug.cgi?id=389965
The while loop condition in stop() was wrong. The loop should continue as long as the PID file still exist, the apache2 PID is still running, and the timeout value hasn't been exceeded yet.
This bug was marked RESOLVED FIXED and it's still happening in 2.2.22 so it looks like despite the ongoing pleas in the comments to fix this I wouldn't be holding my breath (CORRECTION: This issue seems to have been resolved in -r1)