Last active
December 15, 2015 22:49
-
-
Save ivansjg/5335372 to your computer and use it in GitHub Desktop.
init.d script to launch Play framework under Ubuntu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
### BEGIN INIT INFO | |
## END INIT INFO | |
# Path to play install folder | |
PLAY_HOME=/path/to/play_home | |
PLAY=$PLAY_HOME/play | |
# Path to the JVM | |
JAVA_HOME=/usr/lib/jvm/java-6-sun | |
export JAVA_HOME | |
# User running the Play process | |
USER=olhe | |
# Path to the application | |
APPLICATION_PATH=/var/www/playapps/NAME_OF_APPLICATION | |
APPLICATION_MODE=prod | |
#APPLICATION2_PATH=/path/to/application2 | |
#APPLICATION2_MODE=prod | |
. /lib/lsb/init-functions | |
case "$1" in | |
start) | |
echo -n "Starting Play service: " | |
rm -f ${APPLICATION_PATH}/server.pid | |
#rm -f ${APPLICATION2_PATH}/server.pid | |
su $USER -c "${PLAY} start ${APPLICATION_PATH} --%${APPLICATION_MODE}" | |
RETVAL=$? | |
# You may want to start more applications as follows | |
# [ $RETVAL -eq 0 ] && su $USER -c "${PLAY} start ${APPLICATION2_PATH} --%${APPLICATION2_MODE}" | |
# RETVAL=$? | |
if [ $RETVAL -eq 0 ]; then | |
log_end_msg 0 | |
else | |
log_end_msg 1 | |
fi | |
;; | |
stop) | |
echo -n "Shutting down Play service: " | |
${PLAY} stop ${APPLICATION_PATH} | |
# ${PLAY} stop ${APPLICATION2_PATH} | |
RETVAL=$? | |
if [ $RETVAL -eq 0 ]; then | |
log_end_msg 0 | |
else | |
log_end_msg 1 | |
fi | |
;; | |
status) | |
${PLAY} status ${APPLICATION_PATH} | |
# ${PLAY} status ${APPLICATION2_PATH} | |
RETVAL=$? | |
;; | |
*) | |
echo "Usage: $SCRIPTNAME {start|stop|status}" >&2 | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment