Tomcat under daemontools
Tomcat runs nicely under the control of daemontools. Instead of
$ ./shutdown.sh
... 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/catalina.sh run
Should prevent Tomcat from detaching, as daemontools requires.
However, in Tomat subversion revision r918873, catalina.sh 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 eval
s to exec
s. You'll also need to remove the escaping from the doublequotes around shell variables.
The recipe
Install and configure Tomcat and Daemontools.
Copy catalina.sh
to catalina-exec.sh
. Edit catalina-exec.sh
as described above.
Create a daemontools service directory. Your run script will look like this:
#!/bin/bash
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/catalina-exec.sh" run