Skip to content

Instantly share code, notes, and snippets.

@leon
Forked from domdorn/playframework
Created October 15, 2011 19:14
Show Gist options
  • Select an option

  • Save leon/1290012 to your computer and use it in GitHub Desktop.

Select an option

Save leon/1290012 to your computer and use it in GitHub Desktop.

Revisions

  1. @domdorn domdorn created this gist Oct 15, 2011.
    45 changes: 45 additions & 0 deletions playframework
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,45 @@
    # 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
    # http://dominikdorn.com

    description "Description of your app"
    author "Dominik Dorn <[email protected]>"
    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
    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}/server.pid || true
    $PLAY_BINARY dependencies $HOME
    end script

    pre-stop script
    exec $PLAY_BINARY stop $HOME
    end script

    post-stop script
    rm ${HOME}/server.pid || true
    end script

    script
    exec start-stop-daemon --start --exec $PLAY_BINARY --chuid $USER:$GROUP -- start $HOME --%$PROFILE
    end script