Tomcat under daemontools

Tomcat runs nicely under the control of daemontools. Instead of

$ ./
... wait ...
... wait ...

You can use

# svc -d /etc/service/tomcat

Other people have notes about Tomcat and daemontools. Basically, starting Tomcat with

$ /opt/tomcat/current/bin/ run

Should prevent Tomcat from detaching, as daemontools requires.

However, in Tomat subversion revision r918873, changed to using eval instead of exec for the "run" command. This prevents deamontools from stopping Tomcat. To make Tomcat 7.0 work with daemontools, you need to revert this change.

Find the section below

elif [ "$1" = "run" ]; then

and change the evals to execs. You'll also need to remove the escaping from the doublequotes around shell variables.

The recipe

Install and configure Tomcat and Daemontools.

Copy to Edit as described above.

Create a daemontools service directory. Your run script will look like this:


export CATALINA_HOME=/opt/tomcat/current
export JAVA_HOME=/opt/jrockit/current/jre
# set any other environment variables here
#export CATALINA_OPTS="-Xmx512m"

exec 2>&1
exec setuidgid app "${CATALINA_HOME}/bin/" run