[JDEV] using inittab to respawn server

kadokev at msg.net kadokev at msg.net
Tue Apr 10 13:10:24 CDT 2001

> wil at home wrote:
> > Just a note to those who want to make sure that your jabber server is up at
> > all times, use inittab to have it automatically respawned whenever it dies.
> True. However, if you do need to kill it you will then need to a little
> bit of work. Another method is to write a simple script to invoke Jabber
> whenever it notices the process has died. You could then trap a given
> signal in the script to actually kill it. Just another method.

And another method is "daemontools" (from http://cr.yp.to/daemontools.html )
which has as it's primary purpose keeping a daemon running, and respawning
jabberd when it dies.

However you respawn jabber, it is handy to have a shell script that can
handle removing the 'jabber.pid' file, so that the jabberd process will start
after the daemon takes a dive, failing to remove the old pidfile. 

Below I have included a 'run' script to use with daemontools.

I actually use a slightly different version than the one below, as I launch
separate chroot()'ed jabberd processes for each transport, sharing a single
spool directory. I do intend to document my whole installation for those
interested in a more secure Jabber installation.

$ cat /service/jabber/run

# /usr/local/jabber-1.4/run - startup script for Jabber server under daemontools
# Version 0.4
# Kevin Kadow / MSG.Net
# Free to redistribute, if you change the script, change these comments!
export HOME="/usr/local/jabber-1.4"

cd $HOME

su jabber -c "kill `cat ./spool/jabber.pid`"
su jabber -c "rm ./spool/jabber.pid"

# Requires 'setuidgid' from daemontools - http://cr.yp.to/daemontools.html
# or my modified 'chroot-setuidgid' if you want to run under chroot().

exec setuidgid jabber jabberd/jabberd >>./spool/jabber-debug.log 2>&1


Using daemontools, you can kill jabber with 'svc -d jabberd', and bring the
service back later with 'svc -u jabberd'. Full information on installing and
using daemontools is at the web site listed in my run script, above.

I'm not (yet) using daemontool's "multilog" to log the output of jabberd, I'll
probably switch before I write the documentation for my installation. The
multilog process takes the stdout from a service and handles logfile creation
and rotation.

Kevin Kadow
MSG.Net, Inc.

More information about the JDev mailing list