Guides
daemontools is a collection of tools for managing unix services. It is a good alternative to the inittab, ttys, init.d and rc.local as it provides (amongst other things) a simple way to manage all your services plus works the same way on many platforms: Linux, BSD, Solaris etc. Any services supervised by daemontools will be automatically restarted cleanly if they die, plus errors are logged into log files which are automatically rotated to limit the amount of disk space used... by now your convinced and we can get on with setting it all up!
We will start by installing daemontools using Dan J. Bernstein's aka DJB (the author of daemontools) instructions. First lets create the /package directory and set the permissions.
mkdir -p /packagechmod 1755 /packagecd /package
Next you'll need to download the package from DJB's website. If you have wget installed you can run the following command:
wget http://cr.yp.to/daemontools/daemontools-0.76.tar.gz
If your not using wget just download the file and place it in the /package directory we created. Here's a direct clickable link: http://cr.yp.to/daemontools/daemontools-0.76.tar.gz. Once you have the daemontools package in the /package directory we will unpack, patch and install.
NOTE: The errno patch is not required for all users, typically linux users will need to apply with patch. If your running BSD or Solaris you shouldn't need to apply this patch so skip commands on lines 3, 4, 5 of this next section.
tar zvxf daemontools-0.76.tar.gzrm daemontools-0.76.tar.gzcd admin/daemontools-0.76/srcsed -i '/extern int errno/{s/^//* /;s/$/ *//;G;s/$/#include/;}' error.h cd ..package/install
OK now we need to verify that svscan started and is working properly. If your running a BSD system you may need to reboot for svscan to start properly.
ps -efroot 3342 1 0 23:41 ? 00:00:00 /bin/sh /command/svscanboot
root 3344 3342 0 23:41 ? 00:00:00 svscan /service
root 3347 2068 0 23:42 pts/0 00:00:00 grep svscan
Congradulations! you should now have daemontools correctly installed and working on your system. Now you can setup some services to run under daemontools, here are a few examples:
- openssh - openssh daemon
- httpd - apache web server daemon
- ntpd - network time protocol daemon
- mysqld - mysql daemon
- nagios - network monitoring software
Downloads
The tailmc script is something I wrote for tailing the /service/whatever/log/main/current log file of a daemontool service. It will generate a menu listing all services that are currently in the /service directory and also convert the timestamps using tai64nlocal for easy reading.
| File: | tailmc |
| Size: | 2,008 bytes |
| Date: | 2012-07-15 02:09:52 PM |
| MD5: | 4a244d17ccb1f4b77e9c4ca7e6f52b35 |
| SHA-1: | 36cdb8c4d717aa3fc309f9568c1001f691b64e3f |
| RIPEMD-160: | 8f33a40557c997b201a402e25faf898c164113af |
News feed: