Running Lighttpd under daemontools/supervise¶
Lighttpd is well suited to run monitored by the "supervise" program from Daniel J. Bernstein's daemontools package.
To set it up, you must first create a standard service directory structure. In the following example the service directory from where the process starts will be /srv/lighttpd-main/. It consists of the following directory and files:
/srv/lighttpd-main/ # the service directory /srv/lighttpd-main/run # the script that starts lighttpd /srv/lighttpd-main/root/ # lighttpd configuration files go here /srv/lighttpd-main/log/ # the service directory for the logger /srv/lighttpd-main/log/run # the script that starts the logger /srv/lighttpd-main/log/main/ # log files go here
If you're using Gentoo, use /var/services instead of /srv
Note: the "./root/" directory is optional and could be called anything, and we use it here simply to have somewhere to put the configuration file_s_ (we chop up the configuration into several files and use the include statement).
#! /bin/sh exec 2>&1 exec lighttpd -D -f ./root/lighttpd.conf
Apart from your specific settings you probably want to include the following definitions:
server.pid-file = "./root/lighttpd.pid" #server.errorlog must be NOT be set
#! /bin/sh umask 0027 exec setuidgid nobody multilog ./main
The user that is specified to run multilog (nobody in the above example) must have write access to this directory:
chown nobody ./log/main/
After the configuration file is in place, just place a symlink into the svscan service directory (/service in DJB's examples):
ln -s /srv/lighttpd-main /service/
(Please visit Wayne Marshalls overview in case you're lost at this point).
That's all you need to get started.
See also HowToRunLightyWithRunit (for graceful restart wrapper)
Updated by stbuehler about 6 years ago · 11 revisions