Skip to content

Instantly share code, notes, and snippets.

@craigmartin
Last active December 14, 2015 02:39
Show Gist options
  • Save craigmartin/5015607 to your computer and use it in GitHub Desktop.
Save craigmartin/5015607 to your computer and use it in GitHub Desktop.
a general default shell script to start a play app
#!/bin/sh
#
### BEGIN INIT INFO
# Provides: play app
# 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: play web application
# Description: Controls web application written with Play! framework
### END INIT INFO
NAME=myplayapp
DESC='My Play App'
PROJ_HOME=/home/projects/myplayapp
export JAVA_HOME=/opt/jdk/1.6.0_41/
PLAY_HOME=/opt/play-1.1.1
PLAY_USER=www-data
case "$1" in
start)
echo -n "Starting $DESC"
su -s /bin/sh -c 'exec "$0" "$@" > /dev/null' $PLAY_USER -- $PLAY_HOME/play start $PROJ_HOME
echo "."
;;
stop)
echo -n "Stopping $DESC"
su -s /bin/sh -c 'exec "$0" "$@" > /dev/null' $PLAY_USER -- $PLAY_HOME/play stop $PROJ_HOME
echo "."
;;
restart)
echo -n "Restarting $DESC"
su -s /bin/sh -c 'exec "$0" "$@" > /dev/null' $PLAY_USER -- $PLAY_HOME/play restart $PROJ_HOME
echo "."
;;
*)
echo "Usage: service myplayapp {start|stop|restart}"
exit 1
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment