Details
Description
Configuration:
Apache/2.0.40 (Red Hat Linux)
mod_jk 1.2.8
Tomcat 5.5.7
Red Hat Linux 9
j2sdk-1_4_2_07
Background:
In a startup script that is executed at boot time and for server restarts,
it is expected that multiple services are started up sequentially, in a single
thread, and any subsequend service is started only after the the previous one in
the sequence has been initialised fully.
The progress status of the startup script is clearly visible at the console
because each segment of the startup script prints the beginning and the end of
each service initialisation and its success or failure response.
Expected behavior:
jsvc should return control to the command prompt or script with the
appropriate return code only after the Java program it executes has
finished its initialisation.
Actual behavior:
jsvc returns immediately.
The expected behavior is much more critical for re-start than at startup.
A re-start is required when adding or deleting virtual hosts.
As an example, an Apache-httpd mod_jserv Tomcat combination requires the
following operational sequence:
1) Apache shutdown (this blocks ok)
2) jsvc Tomcat shutdown (error has impact here)
3) jsvc Tomcat startup (error has impact here)
4) Apache startup (this blocks ok)
2) and 3) true elapse times vary much depending on server load and especially on
the number of virtual hosts.
It is not acceptable to work around this with time delays because their
required duration cannot be determined.
I am using the following script (adapted from the Tomcat distribution):
JAVA_HOME=/usr/java/j2re1.4.2
CATALINA_HOME=/usr/local/tomcat5
DAEMON_HOME=/usr/local/tomcat5/bin
TOMCAT_USER=tomcat
TMP_DIR=/var/tmp
CATALINA_OPTS=
CLASSPATH=\
$JAVA_HOME/lib/tools.jar:\
$CATALINA_HOME/bin/commons-daemon.jar:\
$CATALINA_HOME/bin/bootstrap.jar
TOMCAT_PID_FILE=/var/run/tomcat.pid
case "$1" in
start)
#
- Start Tomcat
#
$DAEMON_HOME/jsvc \
-user $TOMCAT_USER \
-home $JAVA_HOME \
-Dcatalina.home=$CATALINA_HOME \
-Djava.io.tmpdir=$TMP_DIR \
-outfile $CATALINA_HOME/logs/catalina.out \
-errfile '&1' \
$CATALINA_OPTS \
-cp $CLASSPATH \
-pidfile $TOMCAT_PID_FILE \
-debug \
org.apache.catalina.startup.Bootstrap
#
- To get a verbose JVM
#-verbose \ - To get a debug of jsvc.
#-debug \
;;
stop)
#
- Stop Tomcat
#
#cat $TOMCAT_PID_FILE
PID=$(cat ${TOMCAT_PID_FILE})
kill $PID
;;
restart)
$0 stop
sleep 2
$0 start
;;
*)
echo "Usage tomcat.sh start/stop/restart"
exit 1;;
esac