Created
April 14, 2016 08:12
-
-
Save rrajendran/a1fadc24bf8e11ab3ce5265743023f40 to your computer and use it in GitHub Desktop.
Service script for tomcat
This file contains 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/bash | |
# This is the init script for starting up the | |
# Jakarta Tomcat server | |
# | |
# chkconfig: 345 91 10 | |
# description: Starts and stops the Tomcat daemon. | |
# | |
# Source function library. | |
. /etc/rc.d/init.d/functions | |
# Get config. | |
. /etc/sysconfig/network | |
# Check that networking is up. | |
[ "${NETWORKING}" = "no" ] && exit 0 | |
export JAVA_HOME=/opt/jdk1.8.0_40 | |
export TOMCAT_HOME=/opt/tomcat | |
startup=$TOMCAT_HOME/bin/startup.sh | |
shutdown=$TOMCAT_HOME/bin/shutdown.sh | |
jpda(){ | |
echo -n "Starting Tomcat service in debug" | |
cd $TOMCAT_HOME | |
$TOMCAT_HOME/bin/catalina.sh jpda start | |
echo "Done" | |
} | |
start(){ | |
echo -n "Starting Tomcat service:" | |
cd $TOMCAT_HOME | |
$startup | |
echo "done" | |
} | |
stop(){ | |
echo -n "Shutting down tomcat: " | |
cd $TOMCAT_HOME | |
$shutdown | |
echo "done." | |
} | |
status(){ | |
numproc=`ps -ef | grep 'org.apache.catalina.startup.Bootstrap start' | wc -l` | |
if [ $numproc -gt 1 ]; then | |
echo -e "\e[32mTomcat is running..." | |
else | |
echo -e "\e[31mTomcat is stopped..." | |
fi | |
echo -e "\e[39m" | |
} | |
restart(){ | |
stop | |
start | |
} | |
# See how we were called. | |
case "$1" in | |
start) | |
start | |
;; | |
jpda) | |
jpda | |
;; | |
stop) | |
stop | |
;; | |
status) | |
status | |
;; | |
restart) | |
restart | |
;; | |
*) | |
echo $"Usage: $0 {start|stop|status|restart}" | |
exit 1 | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment