Created
December 9, 2013 23:17
-
-
Save forficate/7882904 to your computer and use it in GitHub Desktop.
Play framework init script for CentOS 6
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/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 | |
. /etc/init.d/functions | |
# User running the Play process | |
USER=myapp | |
# Path to the application | |
APPLICATION_PATH=/opt/myapp | |
CONFIG_FILE=${APPLICATION_PATH}/conf/myapp.live.conf | |
JAVA_OPTS="-Dconfig.file=${CONFIG_FILE}" | |
RETVAL=0 | |
start() { | |
echo -n "Starting Play service: " | |
daemon --user=${USER} --pidfile=${APPLICATION_PATH}/RUNNING_PID ${APPLICATION_PATH}/bin/myapp $JAVA_OPTS &>/dev/null & | |
RETVAL=$? | |
if [ $RETVAL -eq 0 ]; then | |
echo_success | |
else | |
echo_failure | |
fi | |
echo | |
} | |
stop() { | |
echo -n "Shutting down Play service: " | |
killproc -p ${APPLICATION_PATH}/RUNNING_PID ${APPLICATION_PATH}/bin/myapp | |
RETVAL=$? | |
if [ $RETVAL -eq 0 ]; then | |
echo_success | |
else | |
echo_failure | |
fi | |
echo | |
} | |
status() { | |
cat ${APPLICATION_PATH}/RUNNING_PID | |
RETVAL=$? | |
} | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment