Here's a method for managing Tomcat for PAS-Portal development using Unix shell scripts instead of Eclipse.
This is based on the work that Cynick documented in the How to install the portal for development purposes wiki page - unfortunately it was erased after v2
of that page. I have modified it slightly and re-posted it here.
- Download the attached file: mytomcat.sh
and put it somewhere on your path
- make mytomcat.sh executable: chmod u+x mytomcat.sh
- Make all the .sh files in CATALINA_HOME/bin executable: chmod u+x *.sh
- Either create CATALINA_BASE, CATALINA_HOME, and JAVA_HOME variables with the proper file paths in a shell startup script (ex: .profle, .bash_profile) or add them to the beginning of the mytomcat.sh script.
- Copy the conf directory from the unpacked tomcat distribution to where you've defined your CATALINA_BASE.
- Create the following directories under your CATALINA_BASE: logs, temp, webapps, work.
Now you can do the following:
Which should respond with something like this *:
Using CATALINA_BASE: /Users/stephen/dev/mytomcat
Using CATALINA_HOME: /Users/stephen/dev/apache-tomcat-5.5.25
Using CATALINA_TMPDIR: /Users/stephen/dev/mytomcat/temp
Using JRE_HOME: /System/Library/Frameworks/JavaVM.framework/Home
*from a MacOS 10.4.11 system
The default Tomcat install should now be running at: http://127.0.0.1:8080
The mytomcat.sh script supplies the following functions:
- start: start the tomcat server
- stop: start the tomcat server in debug mode
- restart: stop and then start the tomcat server
- killall: terminate the tomcat processes
- status: display status information about running tomcat processes
#!/bin/sh
# set the environment
JAVA_OPTS=""
CATALINA_OPTS=""
# set TIME OUT values
TIMELIMIT=10
SLEEPTIME=1
# Function to wait until all Tomcat processes are killed
waitForTomcatToDie()
{
PROCESSES=`ps auxwww | grep $HOME | grep 'java' | grep 'tomcat' | grep -v 'grep'`
while [ ! -z "$PROCESSES" ] && [ $SECONDS -lt $TIMELIMIT ] && [ $TIMELIMIT -ne 0 ]; do
echo -n "."
sleep $SLEEPTIME
PROCESSES=`ps auxwww | grep $USER | grep 'java' | grep 'tomcat' | grep -v 'grep'`
done
echo ""
if [ ! -z "$PROCESSES" ]; then
PROCESS_ID=`echo $PROCESSES | awk '{ print $2 }'`
echo "Killing process: $PROCESS_ID"
kill -9 $PROCESS_ID
fi
}
# See how we were called.
case "$1" in
start)
$CATALINA_HOME/bin/startup.sh -Dcatalina.base$CATALINA_BASE
;;
debug)
DEBUG_PORT=10001
export JAVA_OPTS="${JAVA_OPTS} -Xdebug -Xrunjdwp:transport=dt_socket,address{DEBUG_PORT},server=y,suspend=n"
$CATALINA_HOME/bin/startup.sh -Dcatalina.base{CATALINA_BASE}
;;
stop)
$CATALINA_HOME/bin/shutdown.sh
waitForTomcatToDie
;;
restart)
$0 stop
$0 start
;;
killall)
waitForTomcatToDie
;;
status)
PROCESSES=`ps auxwww | grep $USER | grep 'java' | grep 'tomcat' | grep -v 'grep'`
if [ -z "$PROCESSES" ]; then
echo "Tomcat is stopped"
else
PROCESS_ID=`echo $PROCESSES | awk '{ print $2 }'`
echo "Tomcat (pid $PROCESS_ID) is running..."
fi
;;
*)
echo "Usage: $0 {start|debug|stop|restart|killall|status}"
exit 1
esac
exit 0
it doesn't work well for CATALINA_BASE Multiple Tomcat 4 Instances