Skip to content

Instantly share code, notes, and snippets.

@leodagdag
Created July 26, 2012 16:22
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save leodagdag/3183045 to your computer and use it in GitHub Desktop.
Save leodagdag/3183045 to your computer and use it in GitHub Desktop.
linux init script for playframework 2
#!/bin/sh
### BEGIN INIT INFO
# Provides: playframework
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/Stop playframework
### END INIT INFO
#
#source some script files in order to set and export environmental variables
#as well as add the appropriate executables to $PATH
PLAYFRAMEWORK_HOME='/opt/playframework/'
export PIDFILE='/opt/playframework/RUNNING_PID'
USER=playframework
GROUP=nogroup
case "$1" in
start)
echo "Starting playframework"
START_CMD="${PLAYFRAMEWORK_HOME}/start -Dparam1=value1"
start-stop-daemon --start -p "${PIDFILE}" --quiet --background --chuid ${USER}:${GROUP} --exec /bin/bash -- ${START_CMD}
;;
stop)
echo "Stopping playframework"
start-stop-daemon -K -p "${PIDFILE}" -u "${USER}" -R 30 ;;
*)
echo "Usage: /etc/init.d/playframework {start|stop}"
exit 1
;;
esac
exit 0
@leodagdag
Copy link
Author

From http://pastebin.com/bPKN97w8

This is the method I use to start a #playframework 2 application as a
service on an ubuntu box:

  1. Package the application with $play dist
  2. Copy the zip on the server
  3. Decompress the zip, for example in /opt/playframework/
    (I use a symbolic folder to be able to update/reverse a version quickly)
    On the server, java should be installed (only java is necessary)

I added a system user:
sudo adduser --system playframework

and changed the owner of /opt/playframework to playframework:nogroup

  1. Use the following start script /etc/init.d/playframework:

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