daemontools-0.76

Introduction to daemontools

The daemontools package is a replacement for inetd or xinetd. The main reason for using it here is because it is recommended for use with qmail and djbdns.

Package information

Installation of daemontools

Install daemontools by running the following commands:

cd admin/daemontools-0.76 && 
patch -Np1 -i ../../daemontools-0.76-errno.patch &&
package/compile &&
cd package && 
sed 's|command|usr/sbin|' boot.inittab > boot.inittab~ && 
mv boot.inittab~ boot.inittab &&
cd ../command &&
sed -e 's|/command:/usr/local/bin:/usr/local/sbin:||' \
    -e 's|command|usr/sbin|' \
    -e 's|/service|/etc/service|g' svscanboot > svscanboot~ &&
mv svscanboot~ svscanboot &&
chmod 555 svscanboot &&
cp * /usr/sbin &&
cd ../package && 
cat /etc/inittab boot.inittab > /etc/inittab~ && 
mv -f /etc/inittab~ /etc/inittab && 
mkdir /etc/service &&
telinit Q

The daemontools package does not come with man pages, so install this package if you want online help with the daemontools programs:

tar xzvf daemontools-0.76-man.tar.gz &&
cp daemontools-man/*.8 /usr/share/man/man8

Command explanations

The first thing to understand in installing any package written by Daniel J. Bernstein, and this includes qmail, djbdns and ucspi-tcp in addition to daemontools, is that he is willing to completely disregard standards if his idea of the correct thing to do differs from an particular standard. Professor Bernstein is a standards body unto himself when it comes to his own software.

It is therefore necessary to make quite a few changes to the installation commands for his packages to get them to install in a manner that is compliant with the Filesystem Hierarchy Standard (FHS). Most of the following commands are due to this difficulty.

cd admin/daemontools-0.76: First off, the package is unpacked in an admin directory. You will find the actual packages two directory levels below this.

package/compile: This command actually compiles the source and prepares the binaries.

Since we are installing the binaries in /usr/sbin rather than creating a non-standard /command directory, several paths have to be changed:

sed 's|command|usr/sbin|' boot.inittab > boot.inittab~
mv boot.inittab~ boot.inittab

In boot.inittab, /command/svscanboot is changed to /usr/sbin/svscanboot.

sed -e 's|/command:/usr/local/bin:/usr/local/sbin:||' \
    -e 's|command|usr/sbin|' \
    -e 's|/service|/etc/service|g' svscanboot > svscanboot~ &&

Here various paths are adjusted in the svscanboot script. In our setup svscan will check the /etc/service directory instead of the /service directory for daemons to run.

cp * /usr/sbin: We must manually copy the binaries to the /usr/sbin directory.

cat /etc/inittab boot.inittab > /etc/inittab~
mv -f /etc/inittab~ /etc/inittab
These commands append a line to /etc/inittab so that init will launch the svscanboot script.

mkdir /etc/service: This command creates the daemontools control directory, which - even if empty - needs to exist for daemontools to run properly.

telinit Q: This command tells the init process to re-read its configuration file (inittab) and act upon any changes that have been made. The svscanboot script is started.

Contents

The daemontools package contains svscanboot, svscan, supervise, svc, svok, svstat, fghack, pgrphack, readproctitle, multilog, tai64n, tai64nlocal, setuidgid, envuidgid, envdir, softlimit and setlock. More detailed descriptions of these commands may be found at http://cr.yp.to/daemontools.html.

Description

svscanboot

svscanboot is simply a script that calls svscan and pipes its output to readproctitle.

svscan

svscan checks the service directory for daemons to run and starts a supervise process for each run script that it finds.

supervise

supervise runs the run script passed to it by svscan and monitors the process the script starts so that if it dies, supervise restarts it.

svc

svc sends signals to processes being run under supervise.

svok

svok checks to see that supervise is running in the directory passed to it.

svstat

svstat prints the status of processes monitored by supervise.

fghack

fghack prevents processes from putting themselves into the background.

pgrphack

pgrphack runs a process in a separate process group.

readproctitle

readproctitle displays log entries in the output of ps.

multilog

multilog is a logging program. It takes output from a daemon and appends it to any number of logs.

tai64n

tai64n is a timestamp generating program.

tai64nlocal

tai64nlocal converts output of tai64n into a human readable format.

setuidgid

setuidgid runs a specified program under a given account's UID and GID.

envuidgid

envuidgid performs the same function as setuidgid, but sets environment variables UID and GID equal to the UID and GID of the account specified.

envdir

envdir runs a given program with environment variables specified by files in a directory.

softlimit

softlimit allows resource limits to be set for a given program.

setlock

setlock locks a file and runs a program.