You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Wolfgang Hackl <wo...@inode.at> on 2005/01/13 23:45:42 UTC
[OT] Making jsvc multiple instances enabled
Hi!
I would like to discuss whether it makes sense to have the commons
daemon able to work with multiple tomcat instances out of the box. Since
I know of at least two jsvc commiters reading this list and I think this
is of interest for tomcat users, too, I start a discussion thread here.
The commons daemon ships a Tomcat5.sh script which starts Tomcat as an
operating system service on UNIX-like systems. The concept which I
propose is to enhance this script and add a wrapper script to the
distribution of the commons daemon. The wrapper script's task is to
enable customisation and to be placed in /etc/init.d (or wherever your
start scripts reside). It exports an individual instance name, the
CATALINA_BASE, additional CATALINA_OPTS and finally calls the Tomcat5.sh
script. Please see the end of this message for full examples of these
scripts.
There are some shortcomings in Tomcat5.sh in terms of multiple instances
that force you either to make an adapted copy of Tomcat5.sh for each
instance (which is impractical for maintenance) or to adapt this script
in a sophisticated way and apply your own concept to make Tomcat5.sh
reusable. Following are the issues that need to be addressed:
- Test whether CATALINA_BASE is set; otherwise (i.e. Tomcat5.sh is
called without wrapper script on a single instance setup) set it to
CATALINA_HOME
- TMP_DIR: change to $CATALINA_BASE/temp
- pid file: make it unique by adding the instance's name to the file name
- CLASSPATH: use commons-daemon.jar from the DAEMON_HOME instead of
CATALINA_HOME's
- improve parameters for the jsvc call:
-- specify the pidfile: -pidfile $PIDFILE \
-- specify the CATALINA_BASE: -Dcatalina.base=$CATALINA_BASE \
- in order to stop the right instance, reuse the pid file specified
previously
So the questions are: Does anyone agree with me and does it make sense
to file a patch or a feature request to the commons daemon team?
Kind regards
Wolfgang
------- start Wrapper Script "/etc/init.d/tomcatTest.sh"
----------------------------
#!/bin/bash
# A wrapper script to set instance dependant variables and start the
tomcat as
# an OS service afterwards
#
export INSTANCE_NAME=Test
export CATALINA_BASE=/usr/local/tomcat/instances/Test
export CATALINA_OPTS=" -Djava.awt.headless=true"
# Call the jsvc script to launch a Tomcat instance
/usr/local/tomcat/Tomcat5.sh $1
------- end Wrapper Script "/etc/init.d/tomcatTest.sh"
----------------------------
------- start adapted "Tomcat5.sh" -- (licence snipped)
---------------------------
JAVA_HOME=/usr/local/java/jdk1.5.0_01
CATALINA_HOME=/usr/local/tomcat/current
# if CATALINA_BASE is not set assign the value of CATALINA_HOME to it
if [ -z "CATALINA_BASE" ]
then
CATALINA_BASE=$CATALINA_HOME
fi
DAEMON_HOME=/usr/local/javalibs/jakarta-commons/daemon/
TOMCAT_USER=www-data
TMP_DIR=$CATALINA_BASE/temp
CATALINA_OPTS="$CATALINA_OPTS"
CLASSPATH=\
$JAVA_HOME/lib/tools.jar:\
$DAEMON_HOME/dist/commons-daemon.jar:\
$CATALINA_HOME/bin/bootstrap.jar
PIDFILE=/var/run/jsvc-$INSTANCE_NAME.pid
case "$1" in
start)
#
# Start Tomcat
#
$DAEMON_HOME/src/native/unix/jsvc \
-user $TOMCAT_USER \
-home $JAVA_HOME \
-pidfile $PIDFILE \
-Dcatalina.home=$CATALINA_HOME \
-Dcatalina.base=$CATALINA_BASE \
-Djava.io.tmpdir=$TMP_DIR \
-outfile $CATALINA_BASE/logs/catalina.out \
-errfile '&1' \
$CATALINA_OPTS \
-cp $CLASSPATH \
org.apache.catalina.startup.Bootstrap
#
# To get a verbose JVM
#-verbose \
# To get a debug of jsvc.
#-debug \
;;
stop)
#
# Stop Tomcat
#
PID=`cat $PIDFILE`
if [ -n $PID ]
then
kill $PID
rm $PIDFILE
fi
;;
restart)
#
# Restart Tomcat
#
$0 stop
$0 start
;;
*)
echo "Usage $0 {start|stop|restart}"
exit 1;;
esac
------- end adapted "Tomcat5.sh"
------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org