Skip to content

Instantly share code, notes, and snippets.

Created October 15, 2011 15:57
Show Gist options
  • Save domdorn/1289753 to your computer and use it in GitHub Desktop.
Save domdorn/1289753 to your computer and use it in GitHub Desktop.
Upstart Script for the PlayFramework 1.x
# Upstart script for a play application that binds to an unprivileged user.
# put this into a file like /etc/init/playframework
# you can then start/stop it using either initctl or start/stop/restart
# e.g.
# start playframework
description "Description of your app"
author "Dominik Dorn <>"
version "1.0"
env PLAY_BINARY=/opt/play/current/play
env HOME=/home/sgwebsite/apps/playapp/
env USER=sgwebsite
env GROUP=sgwebsite
env PROFILE=hyper
start on (filesystem and net-device-up IFACE=lo) or runlevel [2345]
stop on runlevel [!2345]
respawn limit 10 5
umask 022
expect fork
pre-start script
test -x $PLAY_BINARY || { stop; exit 0; }
test -c /dev/null || { stop; exit 0; }
chdir ${HOME}
rm ${HOME}/ || true
$PLAY_BINARY dependencies $HOME
end script
pre-stop script
exec $PLAY_BINARY stop $HOME
end script
post-stop script
rm ${HOME}/ || true
end script
exec start-stop-daemon --start --exec $PLAY_BINARY --chuid $USER:$GROUP --chdir $HOME -- start $HOME --%$PROFILE
end script
Copy link

mcmug8 commented Feb 27, 2013

Quick question is, which location should I save this script to in my ubuntu env?


Copy link

@mcmug8 - in /etc/init/ - this is where upstart saves its service scripts.
@jtammen - I'm seeing the same issue on ubuntu 12.10, dunno why. It worked well for us on 11.04 for some time.

Copy link

@jtammen - this indeed was the problem for me.
The fix was:

  1. Change 'expect fork' to 'expect daemon'
  2. sudo initctl reload-configuration
  3. Restart the machine (this step is mandatory for some reason)

Copy link

What's the meaning of profile=hyper?

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