Skip to content

Instantly share code, notes, and snippets.

@bihe
Created September 25, 2011 18:16
Show Gist options
  • Star 23 You must be signed in to star a gist
  • Fork 12 You must be signed in to fork a gist
  • Save bihe/1240920 to your computer and use it in GitHub Desktop.
Save bihe/1240920 to your computer and use it in GitHub Desktop.
init.d script to launch Play framework under Ubuntu
#!/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
@amirkarimi
Copy link

Does it work on Play 2.2.x? It didn't for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment