Play framework 2.2.x Upstart init script
Below is an Upstart Ubuntu init script for Play 2.2.x.
description "My Play Application"
env USER=
env GROUP=
env APP_HOME=
env APP_NAME=
env PORT=80
env BIND_ADDRESS=0.0.0.0
env EXTRA=""
start on (filesystem and net-device-up IFACE=lo)
stop on runlevel [!2345]
respawn
respawn limit 30 10
umask 022
expect daemon
pre-start script
#If improper shutdown and the PID file is left on disk delete it so we can start again
if [ -f $APP_HOME/RUNNING_PID ] && ! ps -p `cat $APP_HOME/RUNNING_PID` > /dev/null ; then
rm $APP_HOME/RUNNING_PID ;
fi
end script
exec start-stop-daemon \
--pidfile ${APP_HOME}/RUNNING_PID \
--chdir ${APP_HOME} \
--chuid $USER:$GROUP \
--exec ${APP_HOME}/bin/$APP_NAME \
--background --start -- -Dhttp.port=$PORT -Dhttp.address=$BIND_ADDRESS $EXTRA
- APP_HOME should match the folder of your play application
- APP_NAME variable should match ‘:name’ variable in your build.sbt file
- BIND_ADDRESS is the ip the app should listen on
- EXTRA takes additional jvm arguments to pass into the app such as ‘-Dconfig.file=’
- GROUP should match the group you want to run the app as
- PORT is the port the app should listen on
- USER should match the user you want to run the app as