[Techtalk] daemontools HOWTO?

Cynthia Kiser cnk at ugcs.caltech.edu
Thu Apr 1 09:55:11 EST 2004


Quoting Jessica Smith <crystalsinger at mail.com>:
> Does anyone have a mini-HOWTO on daemontools - specifically sample config 
> info?

I use supervise (daemontools) to start and stop all my web
servers. All I did was follow the instructions at 

http://cr.yp.to/daemontools/install.html

to install it. When creating a new service, make a directory within
/service/ and give it a name starting with a ., e.g. 

mkdir /service/.named

Then within that directory create the run script you will use to start
the service. Mine looks like 

#!/bin/sh
exec /software/stow/aolserver-3.3ad13/bin/nsd-oracle -i -u nsadmin -t /web/main/servers/main.tcl -g nsadmin

The main things you have to sort out are logging - the web server I
use does its own logging, including rolling its own logs so I don't
bother with DJB's logging tools - and whether the service you are
starting backgrounds itself - see
http://cr.yp.to/daemontools/faq/create.html#fghack 

Once you have a script that seems to work, make sure that the
permissions are correct (per DJB: normally ./run is mode 755, and the
directory itself is mode 755), then rename your directory to remove
the . so that svscan picks it up.

mv /service/.named /service/named

Check the status supervise gives you about the process using svstat
/service/named. Running that a couple of times the process id should
stay the same and the up XX seconds should increast. If either of
those is not true, then supervise is starting/restarting the service
repeatedly. Use svc -d /service/named to stop it temporarily. Try
adding or removing "exec" to your run script. Check permissions. Rub
your lucky talisman. 

If all works out the output from 'ps axwf' should look something like:

1165 ?        S      0:00 /bin/sh /command/svscanboot 
 1169 ?        S      2:51  \_ svscan /service 
 1171 ?        S      0:00  |   \_ supervise main 
 1382 ?        S      0:01  |   |   \_/software/stow/aolserver-3.3ad13/bin/nsd -i -u nsadmin -t /w\
eb/mian/servers/main.tcl -g nsadmin 
 1418 ?        S      0:16  |   |       \_/software/stow/aolserver-3.3ad13/bin/nsd -i -u nsadmin -\
t /web/main/servers/main.tcl -g nsa 
 1419 ?        S      0:00  |   |           \_/software/stow/aolserver-3.3ad13/bin/nsd -i -u nsadm\
i

When it works, supervise is fabulous. Need to stop all my servers?
sudo svc -d /service/*/ Need to know their uptimes? sudo svstat /service/*/

But I will admit that there are a couple of systems where I have
scripts that run fine from root's command line that I have never
gotten to work under supervise and have finally given up in disgust.


More information about the Techtalk mailing list