Skip to content

Instantly share code, notes, and snippets.

@localdisk
Created January 21, 2014 07:27
Show Gist options
  • Save localdisk/8535737 to your computer and use it in GitHub Desktop.
Save localdisk/8535737 to your computer and use it in GitHub Desktop.
playframework service
#!/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=/play-2.2.0
PLAY=$PLAY_HOME/play
# Path to the JVM
JAVA_HOME=/usr/lib/jvm/java-1.7.0
export JAVA_HOME
# User running the Play process
USER=root
# Path to the applicatiodfile.path=/var/run/play.pidin
APPLICATION_PATH=/var/lib/jenkins/jobs/export/workspace/target/universal/stage/bin
# source function library
. /etc/init.d/functions
RETVAL=0
start() {
echo -n "Starting Play service: "
${APPLICATION_PATH}/play -Dlogger.file=conf/9000-logger.xml -Dpidfile.path=/tmp/9000.pid -Dhttp.port=9000 > /tmp/prototype9000.log &
${APPLICATION_PATH}/play -Dlogger.file=conf/9001-logger.xml -Dpidfile.path=/tmp/9001.pid -Dhttp.port=9001 > /tmp/prototype9001.log &
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo_success
else
echo_failure
fi
echo
}
stop() {
echo -n "Shutting down Play service: "
sudo -u $USER kill `cat /tmp/9000.pid`
sudo -u $USER kill `cat /tmp/9001.pid`
rm -f /var/run/9000.pid
rm -f /var/run/9001.pid
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo_success
else
echo_failure
fi
echo
}
status() {
}
clean() {
rm -f /var/run/9000.pid
rm -f /var/run/9001.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