You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
108 lines
2.0 KiB
108 lines
2.0 KiB
#!/bin/bash
|
|
# chkconfig: 345 20 80
|
|
# description: Play start/shutdown script
|
|
# processname: play
|
|
#
|
|
# Instalation:
|
|
# copy file to /etc/init.d
|
|
# chmod +x /etc/init.d/play
|
|
# chkconfig --add /etc/init.d/play
|
|
# chkconfig play on
|
|
#
|
|
# Usage: (as root)
|
|
# service play start
|
|
# service play stop
|
|
# service play status
|
|
#
|
|
# Remember, you need python 2.6 to run the play command, it doesn't come standard with RedHat/Centos 5.5
|
|
# Also, you may want to temporarily remove the >/dev/null for debugging purposes
|
|
|
|
# Path to play install folder
|
|
PLAY_HOME=/opt/play
|
|
PLAY=$PLAY_HOME/play
|
|
|
|
# Source function library.
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
# Path to the JVM
|
|
JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/
|
|
export JAVA_HOME
|
|
|
|
# User running the Play process
|
|
USER=root
|
|
|
|
# Path to the application
|
|
APPLICATION_PATH=/opt/webapp/
|
|
APPLICATION_MODE=prod
|
|
|
|
#APPLICATION2_PATH=/path/to/application2
|
|
#APPLICATION_MODE=prod
|
|
|
|
# source function library
|
|
. /etc/init.d/functions
|
|
RETVAL=0
|
|
|
|
start() {
|
|
echo -n "Starting Play service: "
|
|
daemon "/opt/webapp/target/start >/dev/null &"
|
|
RETVAL=$?
|
|
|
|
# You may want to start more applications as follows
|
|
# [ $RETVAL -eq 0 ] && su -s /bin/sh $USER -c "${PLAY} start ${APPLICATION2_PATH} --%${APPLICATION_MODE} > /dev/null"
|
|
# RETVAL=$?
|
|
|
|
if [ $RETVAL -eq 0 ]; then
|
|
echo_success
|
|
else
|
|
echo_failure
|
|
fi
|
|
echo
|
|
}
|
|
stop() {
|
|
echo -n "Shutting down Play service: "
|
|
(cd ${APPLICATION_PATH} ; ${PLAY} stop .)
|
|
|
|
RETVAL=$?
|
|
|
|
if [ $RETVAL -eq 0 ]; then
|
|
echo_success
|
|
else
|
|
echo_failure
|
|
fi
|
|
echo
|
|
}
|
|
status() {
|
|
test -f ${APPLICATION_PATH}/RUNNING_PID
|
|
RETVAL=$?
|
|
if [ $RETVAL -eq 0 ]; then
|
|
echo play is running as pid `cat ${APPLICATION_PATH}/RUNNING_PID`
|
|
else
|
|
echo play is not running
|
|
fi
|
|
}
|
|
clean() {
|
|
rm -f ${APPLICATION_PATH}/RUNNING_PID
|
|
}
|
|
case "$1" in
|
|
start)
|
|
clean
|
|
start
|
|
;;
|
|
stop)
|
|
stop
|
|
;;
|
|
restart|reload)
|
|
stop
|
|
sleep 10
|
|
start
|
|
;;
|
|
status)
|
|
status
|
|
;;
|
|
clean)
|
|
clean
|
|
;;
|
|
*)
|
|
echo "Usage: $0 {start|stop|restart|status}"
|
|
esac
|
|
exit 0
|
|
|