Howardism Musings from my Awakening Dementia
My collected thoughts flamed by hubris
Home PageSend Comment

Ugh. I'm not so sure I like this daemontools. It doesn't seem to be the most reliable thing. Granted, it could just be that it can't quite understand Java processes, for this evening it magically decided that our Tomcat wasn't running, so it started another one… and then another one…

Hmm… maybe I will just create a script that doesn't run Tomcat as a background process (like the script does) and then place that script in the /etc/inittab file.

A bit unorthodox, but … I'm not really a system administrator. I just play one on TV.


Hi, the daemontools depend on the runscript not to exit if everything is ok and does.. so there you go.

Have you already found a way to not run tomcat in the background?


Oops sorry, its very simple: just call with run instead of start…


Tomcat Always On

by Howard the Author

Just went through a mildly painful experience trying to get Tomcat (or any daemon for that matter) to run forever, and if it dies (Tomcat sometimes does), it should be restarted. Wanted to make some notes as I tend to forget things.

First, grab a copy of Dan Bernstein's daemontools and extract it… say in /usr/local/daemontools

Like most Unix programs, it won't compile right out of the box due to a bug in Dan's code (see this note for details).

However, it isn't too difficult to get it to compile. Hop down into the directory: admin/daemontools-0.76/src and edit the errno.h file… Change the line that reads:

extern int errno;

To the following:

#include <errno.h>

Now, you can compile the suckah by typing in package/install and it should rock. Basically, it adds an entry to your inittab to start a program called svscan. This program will look for stuff in the (now new) directory: /service

To get tomcat working, grab these goods and extract the archive directly into the /service directory. However, it probably won't work without the run file having a few modifications.

Basically, all you really need is to create a /service/tomcat directory and create a run script that looks something like:

export JAVA_HOME=/usr/java/j2sdk1.4.2_04
export JAVA_OPTS="-Xmx1024M -Xms256M -server" 
export TOMCAT_HOME=/usr/local/tomcat
exec 2>&#38;1
exec setuidgid tomcat ${TOMCAT_HOME}/bin/ run

Now you probably know enough to get any other service running.

BTW: Just by executing the package/install command, it will not only install the programs, but will also automatically start them as well.


These daemontools are not very well documented, but if you need to stop or restart Tomcat (or any other service that you have running under these tools), the command to call is:

svc -d /service/tomcat

This svc program, I guess, does most of the controlling, and it has the following options:

  • -u: Up. If the service is not running, start it. If the service stops, restart it.
  • -d: Down. If the service is running, send it a TERM signal and then a CONT signal. After it stops, do not restart it.
  • -o: Once. If the service is not running, start it. Do not restart it if it stops.
  • -p: Pause. Send the service a STOP signal.
  • -c: Continue. Send the service a CONT signal.
  • -h: Hangup. Send the service a HUP signal.
  • -a: Alarm. Send the service an ALRM signal.
  • -i: Interrupt. Send the service an INT signal.
  • -t: Terminate. Send the service a TERM signal.
  • -k: Kill. Send the service a KILL signal.
  • -x: Exit. supervise will exit as soon as the service is down. If you use this option on a stable system, you're doing something wrong; supervise is designed to run forever.
Tell others about this article:
Click here to submit this page to Stumble It