Skip to content

Instantly share code, notes, and snippets.

@tessro
Created May 15, 2010 21:21
Show Gist options
  • Save tessro/402405 to your computer and use it in GitHub Desktop.
Save tessro/402405 to your computer and use it in GitHub Desktop.
#!/bin/sh
### BEGIN INIT INFO
# Provides: example_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: starts the example_app app server
# Description: starts the example_app app server
### END INIT INFO
set -u
set -e
# Feel free to change any of the following variables for your app:
APP_ROOT=/home/deploy/sites/example_app/current
PID=$APP_ROOT/tmp/pids/glassfish.pid
ENV=production
CMD="/usr/local/jruby/bin/jruby -S glassfish --contextroot / --port 3000 --environment production --runtimes 1 --runtimes-min 1 --runtimes-max 2 -P /home/deploy/sites/example_app/current/tmp/pids/glassfish.pid --daemon /home/deploy/sites/example_app/current"
cd $APP_ROOT || exit 1
sig () {
test -s "$PID" && kill -$1 `cat $PID`
}
case $1 in
start)
sig 0 && echo >&2 "Already running" && exit 0
$CMD
;;
stop)
sig INT && exit 0
echo >&2 "Not running"
;;
force-stop)
sig TERM && exit 0
echo >&2 "Not running"
;;
restart|reload)
sig INT || sig TERM
$CMD
;;
*)
echo >&2 "Usage: $0 <start|stop|restart|force-stop>"
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment