-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtomcat.sh
executable file
·47 lines (34 loc) · 1.11 KB
/
tomcat.sh
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
#!/usr/bin/env sh
set -e
TOMCAT_INSTANCE_HOME="$1"
if [ ! -d $TOMCAT_INSTANCE_HOME ]; then
echo "$TOMCAT_INSTANCE_HOME not found"
exit 1
fi
if [ -f $TOMCAT_INSTANCE_HOME/bin/setenv.sh ]; then
. $TOMCAT_INSTANCE_HOME/bin/setenv.sh
fi
if [ -z $CATALINA_PID ]; then
export CATALINA_PID=/var/run/tomcat_catalina.pid
fi
startScript=$TOMCAT_INSTANCE_HOME/bin/startup.sh
shutdownScript=$TOMCAT_INSTANCE_HOME/bin/shutdown.sh
if [ -f "$CATALINA_PID" ]; then
tomcatPID=`cat "$CATALINA_PID"`
if [ $(ps -p $tomcatPID | wc -l) -gt 1 ]; then
echo "Attempting to shutdown Tomcat . . ."
$shutdownScript || true
sleep 10
echo "Killing Tomcat using process id of $tomcatPID . . ."
kill -9 $tomcatPID || true
echo "Waiting for process $tomcatPID to end . . ."
while [ $(ps -p $tomcatPID | wc -l) -gt 1 ]; do sleep 1; done
echo "Process $tomcatPID has ended . . ."
fi
# remove pid file or tomcat will not start
rm $CATALINA_PID || true
fi
echo "Attempting to start Tomcat via $startScript . . ."
$startScript
echo "Process complete . . ."
exit $?