Skip to content

Instantly share code, notes, and snippets.

@tdebarochez
Last active December 20, 2015 05:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tdebarochez/6082933 to your computer and use it in GitHub Desktop.
Save tdebarochez/6082933 to your computer and use it in GitHub Desktop.
start/stop daemon for play application
#!/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
JAVA_HOME=/usr
export JAVA_HOME
PLAY=/opt/play/play
USER=root
APPLICATION_PATH=/var/www/lclz
TCP_PORT=9001
TCP_ADDRESS=127.0.0.1
CONFIG=application.prod.conf
SBTMEM=256
EXTRA="-Xms128M -Xmx512m -server"
LOG_FILE="/var/log/play.log"
# source function library
. /etc/init.d/functions
RETVAL=0
start() {
echo -n "Starting Play service: "
su -s /bin/sh $USER -c "nohup $APPLICATION_PATH/target/start -Dconfig.resource=$CONFIG -Dhttp.port=$TCP_PORT -Dhttp.address=$TCP_ADDRESS $EXTRA &> LOG_FILE &"
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 > /dev/null
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo_success
else
echo_failure
fi
echo
cd -
}
status() {
cd $APPLICATION_PATH
$PLAY status
RETVAL=$?
cd -
}
clean() {
cd $APPLICATION_PATH
sbt clean compile stage -mem $SBTMEM
[ -f pre-start.sh ] && ./pre-start.sh
cd -
}
case "$1" in
start)
clean
start
;;
stop)
stop
;;
restart|reload)
stop
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