Skip to content

Instantly share code, notes, and snippets.

@feliperazeek
Created July 28, 2011 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save feliperazeek/1111962 to your computer and use it in GitHub Desktop.
Save feliperazeek/1111962 to your computer and use it in GitHub Desktop.
Play Startup Script
#!/bin/sh
#
# /etc/init.d/play -- startup script for play
#
# Path to Play Installation
PLAY_HOME=$HOME/play
PLAY=$PLAY_HOME/play
# User running the Play process
USER=foobar
# Path to the application
APPLICATION_PATH=$HOME/foobar_app
RETVAL=0
start() {
# Play/Elastic Search need this host to IP setting
IP=$(/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2|awk '{print $1}')
grep $IP /etc/hosts 2>&1 >/dev/null
if [ $? -ne 0 ]
then
echo $IP `hostname` >> /etc/hosts
fi
echo -n "Starting Play service: "
su $USER -c "(cd ${APPLICATION_PATH}; ${PLAY} start -XX:MaxPermSize=512m -Xss10m -Xms1000m -Xmx3000m >/dev/null)"
RETVAL=$?
# You may want to start more applications as follows
# [ $RETVAL -eq 0 ] && su $USER -c "${PLAY} start application2"
# RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo OK
else
echo FAILED
fi
echo
}
stop() {
echo -n "Shutting down Play service: "
${PLAY} stop ${APPLICATION_PATH} > /dev/null
# ${PLAY} stop application2 > /dev/null
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo -n "OK"
else
echo -n "Failure"
fi
echo
}
status() {
${PLAY} status ${APPLICATION_PATH}
RETVAL=$?
}
clean() {
rm -f ${APPLICATION_PATH}/server.pid
}
case "$1" in
start)
clean
start
;;
stop)
stop
;;
restart|reload)
stop
sleep 10
start
;;
status)
status
;;
clean)
clean
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment