Skip to content

Instantly share code, notes, and snippets.

@morhook
Forked from leon/play.conf
Last active December 25, 2015 14:29
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 morhook/6991586 to your computer and use it in GitHub Desktop.
Save morhook/6991586 to your computer and use it in GitHub Desktop.
Start play server with init script.
# Upstart script for a play application that binds to an unprivileged user.
# put this into a file like /etc/init/play.conf
#
# This could be the foundation for pushing play apps to the server using something like git-deploy
# By calling service play stop in the restart command and play-start in the restart command.
#
# Usage:
# start play
# stop play
# restart play
#
# WARNING: This is still beta, I have not tested the respawning functionality, but it should work.
#
# http://leon.radley.se
description "PlayFramework 2"
author "Leon Radley <leon@radley.se>"
version "1.0"
env USER=myuser
env GROUP=www-data
env HOME=/home/myuser/app
env APP=myapp
env PORT=9000
env ADDRESS=127.0.0.1
env CONFIG=production.conf
env SBTMEM=256
env EXTRA="-J-Xms128M -J-Xmx512m -J-server"
start on runlevel [2345]
stop on runlevel [06]
respawn
respawn limit 10 5
umask 022
expect daemon
# If you want the upstart script to build play with sbt
pre-start script
chdir $HOME
sbt clean compile stage -mem $SBTMEM
end script
exec start-stop-daemon --pidfile ${HOME}/RUNNING_PID --chuid $USER:$GROUP --exec ${HOME}/target/universal/stage/bin/${APP} --background --start -- -Dconfig.resource=$CONFIG -Dhttp.port=$PORT -Dhttp.address=$ADDRESS $EXTRA
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment