Apache Tomcat¶
Table of Contents
Layout¶
For installations done using the Wizard, the Apache Tomcat (CATALINA) home directory is:
/home/tomcat/apache-tomcat-v/
Where apache-tomcat-v is the version you chose to install.
The CATALINA_HOME variable is set both in the Tomcat init script as well as setenv.sh files.
Starting and Stopping¶
There are two ways to start/stop/restart Tomcat.
- Via Module, using the Stop/Start/Restart buttons as shown below:
- Via SSH, using the following commands
1 | /etc/init.d/tomcat { start | stop | restart | status }
|
Init Script¶
The Tomcat init script is located in /etc/init.d and has the following content.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | #!/bin/bash
### BEGIN INIT INFO
# Provides: tomcat
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/Stop Tomcat server
### END INIT INFO
# Source function library.
. /etc/environment; #Catalina variables
. $CATALINA_HOME/bin/setenv.sh
RETVAL=$?
function start(){
echo "Starting Tomcat"
/bin/su - tomcat $CATALINA_HOME/bin/startup.sh
RETVAL=$?
}
function stop(){
echo "Stopping Tomcat"
/bin/su - tomcat -c "$CATALINA_HOME/bin/shutdown.sh 60 -force"
RETVAL=$?
}
case "$1" in
start)
start;
;;
stop)
stop;
;;
restart)
echo "Restarting Tomcat"
stop;
start;
;;
status)
if [ -f "${CATALINA_PID}" ]; then
TOMCAT_PID=$(cat "${CATALINA_PID}")
echo "Tomcat is running with PID ${TOMCAT_PID}";
RETVAL=1
else
echo "Tomcat is not running";
RETVAL=0
fi
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
exit $RETVAL
|