Created
March 8, 2011 11:02
-
-
Save filiptepper/860144 to your computer and use it in GitHub Desktop.
start/stop/restart JRuby application running on Kirk
This file contains hidden or 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 | |
set -u | |
NAME=<set your application name here> | |
DIRECTORY=<set your application directory here> | |
PIDFILE=/var/run/$NAME.pid | |
DAEMON="/usr/local/rvm/bin/rvm exec rackup" | |
DAEMON_ARGS="-s Kirk config.ru -p 3000 -P $PIDFILE" | |
SCRIPTNAME=/etc/init.d/$NAME | |
do_start() | |
{ | |
start-stop-daemon --start --background --quiet -d $DIRECTORY --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_ARGS | |
} | |
do_stop() | |
{ | |
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE | |
RETVAL="$?" | |
rm -f $PIDFILE | |
return "$RETVAL" | |
} | |
case "$1" in | |
start) | |
echo "Starting $NAME..." | |
do_start | |
if [ "$?" -eq 0 ] ; then | |
echo "OK!" | |
else | |
echo "Failed..." | |
fi | |
;; | |
stop) | |
echo "Stopping $NAME..." | |
do_stop | |
if [ "$?" -eq 0 ] ; then | |
echo "OK!" | |
else | |
echo "Failed..." | |
fi | |
;; | |
restart|force-reload) | |
echo "Restarting $NAME..." | |
do_stop | |
sleep 2 | |
do_start | |
;; | |
*) | |
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 | |
exit 3 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment