# The functions below are used to manage a box where two or more instances
# of tomcat are running simultaneously.
#
# Ports used by Tomcat (see $TOMCAT_BASE/conf/server.xml):
# 1)
# 2)
#
# 3)
#
#
# The first two ports need to be modified to set up a new instance of tomcat.
# the third port is for a ajp server that talks to aphache and it does not need to be
# changed.
# http://tomcat.apache.org/tomcat-4.0-doc/config/ajp.html
#
#
#
# I) Creating the new set of code.
#
#
# Suppose you want an instance of tomcat to run on port 8070
# and the primary set of tomcat files are in
# TOMCAT_BASE=/usr/local/apache-tomcat-5.5.23
#
# 1) Create a duplicate set of the tomcat files
# cp -R /usr/local/apache-tomcat-5.5.23 /usr/local/apache-tomcat-5.5.23_8070
#
# 2) Modify the file /usr/local/apache-tomcat-5.5.23_8070/conf/server.xml
# a) set to
# or whatever port you like for shutdown.
#
#
# II) Examples of using the scripts
# tomstart - will start an instance of tomcat on 8080
# tomstart 8070 - will start an instance of tomcat on 8070
# tomkill - will kill -9 an instance of tomcat on 8080
# tomskill 8070 - will kill -9 an instance of tomcat on 8070
# ect.
#
# III) I have the line
# source ~/TOMCAT_SCRIPTS.sh
# in my .bashrc file where TOMCAT_SCRIPTS.sh is this file
#
#
# J. Silvis Nov 2007
# **********************************************************************************************
export TOMCAT_BASE=/usr/local/apache-tomcat-5.5.23
function tom {
if [ -n "$1" ]; then
cd ${TOMCAT_BASE}_${1}
else
cd $TOMCAT_BASE
fi
}
# Start tomcat server:
# tomstart portnumber will start a server that is is
# within the directory $TOMCAT_BASE_$portnumber and will be
# on the port: portnumber Otherwise stop the server on 8080
function tomstart
{
export CATALINA_HOME=$TOMCAT_BASE
port=8080
if [ -n "$1" ]; then
port=${1}
export CATALINA_HOME=${CATALINA_HOME}_$port
fi
export CATALINA_PID=${CATALINA_HOME}/temp/tomcat.pid
${CATALINA_HOME}/bin/catalina.sh run &
sleep 4 # wait for CATALINA_PID file to be written
termtitle "Tomcat on port $port pid `cat $CATALINA_PID`"
}
# Stop tomcat server:
# tomstop portnumber will start a server that is is
# within the directory $TOMCAT_BASE_$portnumber and will be
# on the port: portnumber Otherwise stop the server on 8080
function tomstop {
export CATALINA_HOME=$TOMCAT_BASE
if [ -n "$1" ]; then
export CATALINA_HOME=${CATALINA_HOME}_${1}
fi
$CATALINA_HOME/bin/shutdown.sh
termtitle "$USER"
}
# kill -9 the tomcat server:
# tomkill portnumber will start a server that is is
# within the directory $TOMCAT_BASE_$portnumber and will be
# on the port: portnumber Otherwise stop the server on 8080
function tomkill
{
export CATALINA_HOME=$TOMCAT_BASE
if [ -n "$1" ]; then
export CATALINA_HOME=${CATALINA_HOME}_${1}
fi
export CATALINA_PID=${CATALINA_HOME}/temp/tomcat.pid
kill -9 `cat $CATALINA_PID`
rm $CATALINA_PID
termtitle "$USER"
}
# gives the pid of the tomcat server:
# tomkill portnumber will start a server that is is
# within the directory $TOMCAT_BASE_$portnumber and will be
# on the port: portnumber Otherwise stop the server on 8080
function tompid
{
export CATALINA_HOME=$TOMCAT_BASE
if [ -n "$1" ]; then
export CATALINA_HOME=${CATALINA_HOME}_${1}
fi
export CATALINA_PID=${CATALINA_HOME}/temp/tomcat.pid
cat $CATALINA_PID
}
# Go to the root of the dspace development tree
function dsrt {
cd ~/Documents/workspace/trunk_8070
}
# Copy dspace war files into tomcat
function tomds
{
export CATALINA_HOME=$TOMCAT_BASE
dsCodeRoot=~/Documents/workspace/trunk
if [ -n "$1" ]; then
export CATALINA_HOME=${CATALINA_HOME}_${1}
dsCodeRoot=${dsCodeRoot}_${1}
cp ${dsCodeRoot}/build/*war ${CATALINA_HOME}/webapps/.
else
echo -n "You are putting war files into the 8080 server ... proceed (Y/N) ? "
read PROCEED
ymatch=`echo $PROCEED | grep -Ei '^y(es)?$' | wc -l`
if [ $ymatch == "1" ] ;
then
cp ${dsCodeRoot}/build/*war ${CATALINA_HOME}/webapps/.
fi
fi
}
Comments
Thanks for your insight for the great written piece. I am glad I have taken the time to read this.
Posted by: wheel well truck tool boxes | November 20, 2010 3:03 PM