updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / playframework / skeleton_playapp
blob5b66dcbe4686248276239007781cc15f96058b00
1 #!/bin/bash
2 # /etc/rc.d/skeleton_playapp : a generic playframework daemon for multiple instance of play applications (with a symlink).
3 # @see /etc/conf.d/playapp_sample for usage
5 NAME=`basename $0`
6 . /etc/rc.conf
7 . /etc/rc.d/functions
8 . /etc/conf.d/$NAME
9 . /etc/profile.d/jre.sh
11 USER=${USER-"root"}
12 pidfile=$PLAY_APP/server.pid
13 PID=`cat $pidfile 2> /dev/null`
14 [[ -e $pidfile ]] && ( [ -n "`ps -p $PID | grep $PID`" ] || rm -f $pidfile) # rm pidfile if not process is running
15 PID=`cat $pidfile 2> /dev/null`
17 case $1 in
18 start)
19 stat_busy "Starting Play framework $PLAY_APP app"
20 if [[ -z $PID ]] && su - $PLAY_USER -c "export PATH=$PATH; play start $PLAY_APP $PLAY_ARGS"; then
21 add_daemon $NAME
22 stat_done
23 else
24 stat_fail
25 exit 1
29 stop)
30 stat_busy "Stopping Play framework $PLAY_APP app"
31 if [[ ! -z $PID ]] && play stop $PLAY_APP; then
32 rm_daemon $NAME
33 stat_done
34 else
35 stat_fail
36 exit 1
40 restart)
41 $0 stop
42 $0 start
46 echo "Usage: $0 {start|stop|restart}" >&2
47 exit 1
49 esac