Running Jabber under Supervise

Jabber, in its default installation under most operating systems, is started as a daemon via the system startup process. This form of invocation has several disadvantages, one of the being that when jabberd dies, it will not come up again, automagically.

To remedy this problem, we can start jabberd under the supervise "daemon babysitter" process of DJB fame. This document explains how to do this.

This HOWTO document is meant as a guide to users new to unix and the daemontools concept. The author cannot be held liable for any damages or complications that might occur when you follow these instructions. Use this HOWTO at your own risk.

Installation of Jabber
Of course you'll need a working Jabber installation. Before proceeding further, I urge you to move the startup scripts local to your system which invoke jabberd to a safe place, or remove the symlinks used by the init scripts to start it at boot.

On FreeBSD

# cd /usr/local/etc/rc.d
# mkdir .disabled
# mv .disabled
On Debian Linux
# cd /etc/rc2.d
# mkdir .disabled
# mv S20jabberd .disabled
startup script names can vary across versions and platforms, the above is just meant as an example.
the "#" in front of the lines implies that you are doing this as user root.

Install Daemontools
Daemontools is the package containing supervise. It can be installed either from source (download via the link above), from "ports" (on the *BSD platforms), or from several RPM or DEB packages (mostly unsupported software, YMMV).

After having installed the daemontools you'll need a /service directory, serving as a "symlink farm" to the packages to monitor, a startup script which invokes svscan, and another directory structure holding the tree of run and log scripts.

Example on FreeBSD
jabberd is assumed to run under userid 'jabber', the log process writes its output under userid 'log'. please ensure that these accounts/groups exist before doing the following.

# mkdir /service
# mkdir /usr/local/service
# mkdir /var/log/svscan
# chown log:log /var/log/svscan
# echo 'env - PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/bin \
  csh -cf 'svscan /service | setuidgid log multilog t /var/log/svscan &' \
# chmod 0700 /usr/local/etc/rc.d/
# mkdir /usr/local/service/jabberd
# echo 'exec setuidgid jabber \
  /usr/local/sbin/jabberd -c /usr/local/etc/jabber.xml -D 2>&1' \
# chmod 0700 /usr/local/service/jabberd/run
# mkdir /usr/local/service/jabberd/log
# mkdir /usr/local/service/jabberd/log/jabberd
# chown log:log /usr/local/service/jabberd/log/jabberd
# echo 'exec setuidgid log multilog s100000 n20 ./jabberd' \
# chmod +t /usr/local/service/jabberd
we now have
  • a (hopefully functioning) preinstalled version of the daemontools in place
  • a script invoking svscan at system boot time
  • the skeleton to make the service for jabberd work
we should start the svscan now and ensure that it runs
# cd /
# /usr/local/etc/rc.d/
# ps ax | grep svscan
there should be a visible svscan process and the corresponding multilog instance.

Test Run
edit /usr/local/etc/jabber.xml to switch the elogger service to <stderr/>, first!

# cd /usr/local/service/jabber
# ./run
[...] startup message should be displayed here [...]
# cd log
# ./run
# cat jabberd/current

Going Live
now that we ensured jabberd and his multilog process functioning, we'll hook up the service to its "life support system"

# cd /service
# ln -s /usr/local/service/jabberd
# svstat ./jabberd ./jabberd/log
./jabberd: up (pid XXXX) X seconds
./jabberd/log: up (pid XXXX) X seconds
repeat the last step, invoking svscan after waiting for a few seconds, to ensure that the uptime of the processes increases. if it starts over at 0 seconds, something is broken and supervise tries to restart the corresponding process through its run script.

have fun and enjoy... you now got an auto-restarting jabberd

Copyright © 1996–2017 Karsten W. Rohrbach. All rights reserved.  —  Hosted on infrastructure.