Skip to content

Instantly share code, notes, and snippets.

@rchampourlier
Created July 12, 2011 22:03
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 rchampourlier/1079091 to your computer and use it in GitHub Desktop.
Save rchampourlier/1079091 to your computer and use it in GitHub Desktop.
SystemV service startup script for a Ruby On Rails app (redmine) with passenger
#!/bin/bash
#
# chkconfig: - 86 14
### BEGIN INIT INFO
# Provides: redmine
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: true
# Short-Description: redmine (Rails app) provided through Passenger Standalone
### END INIT INFO
USER=www
RVM=rvm
RVM_GEMSET=ree@redmine
PASSENGER=passenger
ADDRESS=127.0.0.1
PORT=3000
ENVIRONMENT=production
APP="/var/www/railsapps/redmine"
APPNAME="redmine"
SET_PATH="cd $APP; $RVM use $RVM_GEMSET;"
CMD="$SET_PATH $PASSENGER start -a $ADDRESS -p $PORT -e $ENVIRONMENT -d"
CMD_STOP="$SET_PATH $PASSENGER stop -p $PORT"
case "$1" in
start)
echo "Starting $APP_NAME passenger"
echo $CMD
su - $USER -c "$CMD"
;;
stop)
echo "Stopping $APP_NAME passenger"
cd $APP
su - $USER -c "$CMD_STOP"
;;
*)
echo "Usage: $0 start|stop" >&2
exit 3
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment