Skip to content

Instantly share code, notes, and snippets.

@joshua
Created September 27, 2010 19:30
Show Gist options
  • Select an option

  • Save joshua/599656 to your computer and use it in GitHub Desktop.

Select an option

Save joshua/599656 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# trinidad JRuby Application Server
#
# chkconfig: 2345 85 15
# description: Trinidad application server
#
# source function library
. /etc/rc.d/init.d/functions
RETVAL=0
prog="trinidad"
uid="deploy"
# Rails application directory
APP_ROOT=/home/deploy/c11/current
# Use RVM wrapped executable
# ensures proper JRuby environment
TRINIDAD=/usr/local/rvm/bin/jruby_trinidad
OPTIONS="--config $APP_ROOT/config/trinidad.yml -t"
PID_FILE=$APP_ROOT/tmp/pids/trinidad.pid
LOG_FILE=$APP_ROOT/log/trinidad.log
LOG_FILE_LOCK=$LOG_FILE.lck
start () {
local cmd
echo -n $"Starting $prog: "
cmd="cd $APP_ROOT && $TRINIDAD $OPTIONS &>/dev/null"
daemon --user=$uid --pidfile=$PID_FILE "$cmd"
RETVAL=$?
echo
[ "$RETVAL" = 0 ] && touch /var/lock/subsys/trinidad
return $RETVAL
}
stop () {
echo -n $"Stoping $prog: "
killproc -p $PID_FILE $TRINIDAD
RETVAL=$?
echo
[ -f $LOG_FILE_LOCK ] && rm -f $LOG_FILE_LOCK
[ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/trinidad
}
restart () {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
restart
;;
condrestart|try-restart)
[ -f /var/lock/subsys/trinidad ] && restart
;;
status)
status -p $PID_FILE trinidad
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
exit 1
esac
exit $RETVAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment