daemontools, Apache, and the Whole Process Group

 

daemontools, Apache, and the Whole Process Group

Published 2011-08-05

There went a few hours of my life.

My server configurator detects changes in config files and will restart Apache if needed. Since I use daemontools to handle my daemons, the configurator does a svc -t /service/apache when it wants to kick Apache to re-read its configs (yes, it should be a SIGHUP – I changed it).

After an update the other day, I started seeing all my daemons getting kicked when a process kicked Apache. Ugh. Essentially, supervise, the daemontools supervisor, was getting killed by the svc -t call. Turns-out Apache kills its entire process group when it gets a SIGKILL. Of, course, djb has already fixed this problem, so here’s the correct run file for apache:

#!/bin/bash

exec 2>&1
exec pgrphack /usr/sbin/httpd -DFOREGROUND

Maybe this will save you a few hours.