Skip to content

Instantly share code, notes, and snippets.

@mugli
Forked from bihe/init.d play
Created November 19, 2013 11:30
Show Gist options
  • Save mugli/7544047 to your computer and use it in GitHub Desktop.
Save mugli/7544047 to your computer and use it in GitHub Desktop.
#!/bin/sh
### BEGIN INIT INFO
## END INIT INFO
# Path to play install folder
PLAY_HOME=/usr/share/play
PLAY=$PLAY_HOME/play
# Path to the JVM
JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk
export JAVA_HOME
# User running the Play process
USER=www-data
# Path to the application
APPLICATION_PATH=/var/www/playapps/NAME_OF_APPLICATION
. /lib/lsb/init-functions
case "$1" in
start)
echo -n "Starting Play service: "
rm -f ${APPLICATION_PATH}/server.pid
su $USER -c "${PLAY} start ${APPLICATION_PATH} --%production >/dev/null"
RETVAL=$?
# You may want to start more applications as follows
# [ $RETVAL -eq 0 ] && su $USER -c "${PLAY} start application2"
# RETVAL=$?
if [ $RETVAL -eq 0 ]; then
log_end_msg 0
else
log_end_msg 1
fi
;;
stop)
echo -n "Shutting down Play service: "
${PLAY} stop ${APPLICATION_PATH} > /dev/null
# ${PLAY} stop application2 > /dev/null
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
log_end_msg 0
else
log_end_msg 1
fi
;;
status)
${PLAY} status ${APPLICATION_PATH}
RETVAL=$?
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status}" >&2
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment