aboutsummaryrefslogtreecommitdiff
path: root/system/apache-tomcat/rc.tomcat
blob: 97966a68cefc20b0cbbbb49d5dfe9660c88202eb (plain)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/sh
# Start/stop/restart apache-tomcat.
# $Id: rc.apache-tomcat,v 1.2.0 2013/11/30
# Authors: Heinz Wiesinger <pprkut@liwjatan.at>, Vincent Batts <vbatts@hashbangbash.com>
# ---------------------------------------------------------------------------

# Load tomcat specific java vm options
. /etc/tomcat/tomcat-java.conf

# Load environment variables
. /etc/profile.d/apache-tomcat.sh
if [ -e "/etc/profile.d/openjdk.sh" ]; then
  . /etc/profile.d/openjdk.sh
else
  . /etc/profile.d/jdk.sh
fi

PIDFILE="/var/spool/tomcat/tomcat.pid"
LOGFILE="/var/log/tomcat/tomcat.log"

CLASSPATH="$CATALINA_BASE/bin/bootstrap.jar:/usr/share/java/commons-daemon.jar"
for i in $CATALINA_LIBDIR/*.jar; do
  CLASSPATH=$CLASSPATH:$i
done

USER="tomcat"

TOMCAT_CMD="/usr/bin/jsvc -user $USER -cp $CLASSPATH \
  -pidfile $PIDFILE -outfile $LOGFILE -errfile $LOGFILE \
  -Xms$MEMALLOC_MIN -Xmx$MEMALLOC_MAX -Xss$STACK -XX:MaxPermSize=$MAXPERMSIZE \
  -Dcatalina.home=$CATALINA_HOME -Dcatalina.base=$CATALINA_BASE \
  -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager \
  -Djava.util.logging.config.file=$CATALINA_BASE/conf/logging.properties \
  -Djava.awt.headless=true org.apache.catalina.startup.Bootstrap"

tomcat_start() {
  echo -n "Starting Apache Tomcat ... "
  if [ -e "$PIDFILE" ]; then
    echo "already running!"
  else
    unset DISPLAY
    cd /var/lib/tomcat
      $TOMCAT_CMD
    echo "done!"
  fi
}

tomcat_stop() {
  echo -n "Stopping Apache Tomcat ... "
  if [ -e "$PIDFILE" ]; then
    kill -TERM $(cat $PIDFILE) > /dev/null 2>&1
    echo "done!"
    rm -f "$PIDFILE"
  else
    echo "not running!"
  fi
}

# Restart tomcat:
tomcat_restart() {
  tomcat_stop
  sleep 1
  tomcat_start
}

case "$1" in
'start')
  tomcat_start
  ;;
'stop')
  tomcat_stop
  ;;
'restart')
  tomcat_restart
  ;;
*)
  echo "usage $0 start|stop|restart"
esac