Daemontools

Daemontools

As i was running Linux-VServer, i couldn’t use runit (that is, i couldn’t figure how to do it); so i was using daemontools.

As inittab doesn’t work within a vserver, you need an init script (see attachment attachment:svscan) to start svscan; i used http://flounder.net/qmail/svscan-init as a template for that (i don’t know how google found that, as it seems no site links this file, and the site seems down now).

Services

The basic idea is always the same; you have a daemon and a log daemon; the start scripts are named “run”.

I maintain the services in /etc/sv/, and symlink the services i want to run to /etc/service.

You could use different log users, i chose to just use always the same user log and to put the logs into /var/log/sv/*/:

The examples below will only describe the main run and additional files.

spawn-fcgi

You will need the spawn-fcgi program; you can use the one from http://cgit.stbuehler.de/gitosis/spawn-fcgi/about/ (“version 2.0”, debian packages are in my repo http://debian.stbuehler.de), or version 1.6.x from http://redmine.lighttpd.net/projects/spawn-fcgi (which doesn’t support the -l option yet, so you have to set limits directly via ulimit if you want them).

Don’t use the one from older lighttpd versions (1.4 and 1.5), as it doesn’t support some important options (-U, -G), and you need an extra wrapper script of the following form (e.g. as ./php in your service directory):
If you have to, you can use something like this (i really recommend using 1.6.x or 2.0):