Created
September 26, 2011 03:04
-
-
Save qichunren/1241531 to your computer and use it in GitHub Desktop.
tomcat daemon script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
### BEGIN INIT INFO | |
# Provides: tomcat | |
# Required-Start: $local_fs $remote_fs $network $syslog | |
# Required-Stop: $local_fs $remote_fs $network $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: starts the tomcat web server | |
# Description: starts tomcat using start-stop-daemon | |
### END INIT INFO | |
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin | |
START_DAEMON=/opt/apache-tomcat-6.0.33/bin/startup.sh | |
STOP_DAEMON=/opt/apache-tomcat-6.0.33/bin/shutdown.sh | |
NAME=tomcat | |
DESC=tomcat | |
set -e | |
. /lib/lsb/init-functions | |
case "$1" in | |
start) | |
tomcat_pid=`ps -ef | grep apache | grep tomcat | grep java | egrep -v grep | awk '{print $2}'` | |
if [ -n "$tomcat_pid" ]; then | |
echo "Tomcat is running." | |
exit 1; | |
fi | |
echo -n "Starting $DESC:\n $START_DAEMON \n" | |
$START_DAEMON | |
;; | |
stop) | |
tomcat_pid=`ps -ef | grep apache | grep tomcat | grep java | egrep -v grep | awk '{print $2}'` | |
if [ -z "$tomcat_pid" ]; then | |
echo "Tomcat is not running." | |
exit 1; | |
fi | |
echo -n "Stopping $DESC:\n $STOP_DAEMON \n " | |
$STOP_DAEMON | |
;; | |
restart|force-reload) | |
tomcat_pid=`ps -ef | grep apache | grep tomcat | grep java | egrep -v grep | awk '{print $2}'` | |
if [ -n "$tomcat_pid" ]; then | |
echo -n "Restarting $DESC: \n $STOP_DAEMON \n" | |
$STOP_DAEMON | |
sleep 5 | |
fi | |
echo -n "starting $DESC: \n $START_DAEMON \n" | |
$START_DAEMON | |
echo "Starting, please wait for about 50 seconds." | |
sleep 20 | |
;; | |
*) | |
echo "Usage: $NAME {start|stop|restart}" >&2 | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment