[ale] Tomcat startup script
Mike Millson
mgm at atsga.com
Fri Feb 1 12:59:07 EST 2002
I created a Tomcat startup script from a couple sources. Seems to be
working, just a couple questions.
The script references a file called /var/run/tomcat.pid. I don't have a on
my system (RH 7.1, ver 2.4.9-21). Do I need to create it? It looks like it's
just a file w/ a # in it, the process id I gather? What process id
would/should I give tomcat?
Also, the script references /var/lock/subsys/tomcat4, another file I don't
have. What is that file for? Do I need to create it somehow?
If anyone has any suggestions for improvement, let me know. I'm basically
mimicing things I found in other startup files, not knowing all that much
what's going on.
Here is the history:
1) Installed Tomcat binaries
2) Installed Sund JDK 1.4
3) Created tomcat4 group
4) Created tomcat4 user
5) Added the following to $TOMCAT_HOME/bin/startup.sh and shutdown.sh:
JAVA_HOME=/usr/java/j2sdk1.4.0
TOMCAT_HOME=/usr/local/jakarta-tomcat-4.0.1
CLASS_PATH=.:$JAVA_HOME/lib/tools.jar
export JAVA_HOME TOMCAT_HOME CLASSPATH
6) Copied the script below to /etc/init.d/tomcat4 and did a chmod +x on it.
7) Added tomcat4 to rc.d with chkconfig --add tomcat4
#!/bin/sh
#
# Startup script for Tomcat, the Apache Servlet Engine
#
# chkconfig: 345 80 20
# description: Tomcat is the Apache Servlet Engine
# processname: tomcat
# pidfile: /var/run/tomcat.pid
#
# Mike Millson <mgm at atsga.com>
#
# version 1.01 - Cross between Tomcat RPM and Chris Bush scripts
# Tomcat name :)
TOMCAT_PROG=tomcat4
# if TOMCAT_USER is not set, use tomcat4 like Apache HTTP server
if [ -z "$TOMCAT_USER" ]; then
TOMCAT_USER="tomcat4"
fi
RETVAL=0
# start and stop functions
start() {
echo -n "Starting tomcat4: "
chown -R $TOMCAT_USER:$TOMCAT_USER /usr/local/jakarta-tomcat-4.0.1/logs
chown -R $TOMCAT_USER:$TOMCAT_USER /usr/local/jakarta-tomcat-4.0.1/work
chown -R $TOMCAT_USER:$TOMCAT_USER
/usr/local/jakarta-tomcat-4.0.1/webapps/*
su -l $TOMCAT_USER -c '/usr/local/jakarta-tomcat-4.0.1/bin/startup.sh'
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/tomcat4
return $RETVAL
}
stop() {
echo -n "Stopping tomcat4: "
su -l $TOMCAT_USER -c '/usr/local/jakarta-tomcat-4.0.1/bin/shutdown.sh'
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/tomcat4 /var/run/tomcat4.pid
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
# Ugly hack
# We should really make sure tomcat
# is stopped before leaving stop
sleep 2
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit $RETVAL
---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be
sent to listmaster at ale dot org.
More information about the Ale
mailing list