Skip to content

Instantly share code, notes, and snippets.

@douhashi
Created February 9, 2012 08:46
Show Gist options
  • Save douhashi/1778546 to your computer and use it in GitHub Desktop.
Save douhashi/1778546 to your computer and use it in GitHub Desktop.
redmine service conf
#!/bin/bash
#
# unicorn_rails_redmine Startup script for unicorn.
#
# chkconfig: - 85 15
# description: redmine on unicorn start/stop script.
#
#
# set rvm environment valiables.
#
export PATH=/home/app/.rvm/gems/ruby-1.8.7-head@redmine/bin:/home/app/.rvm/gems/ruby-1.8.7-head@global/bin:/home/app/.rvm/rubies/ruby-1.8.7-head/bin:/home/app/.rvm/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/redmine/bin
export GEM_HOME=/home/app/.rvm/gems/ruby-1.8.7-head@redmine
export GEM_PATH=/home/app/.rvm/gems/ruby-1.8.7-head@redmine:/home/app/.rvm/gems/ruby-1.8.7-head@global
export BUNDLE_PATH=
export MY_RUBY_HOME=/home/app/.rvm/rubies/ruby-1.8.7-head
export IRBRC=/home/app/.rvm/rubies/ruby-1.8.7-head/.irbrc
set -u
set -e
APP_NAME=redmine
APP_ROOT="/var/rails/$APP_NAME"
CNF="$APP_ROOT/config/unicorn.rb"
PID="$APP_ROOT/tmp/pids/unicorn.pid"
ENV=production
UNICORN_OPTS="-D -E $ENV -c $CNF"
old_pid="$PID.oldbin"
cd $APP_ROOT || exit 1
sig () {
test -s "$PID" && kill -$1 `cat $PID`
}
oldsig () {
test -s $old_pid && kill -$1 `cat $old_pid`
}
case ${1-help} in
start)
sig 0 && echo >&2 "Already running" && exit 0
cd $APP_ROOT ; unicorn_rails $UNICORN_OPTS
;;
stop)
sig QUIT && exit 0
echo >&2 "Not running"
;;
force-stop)
sig TERM && exit 0
echo >&2 "Not running"
;;
restart|reload)
sig HUP && echo reloaded OK && exit 0
echo >&2 "Couldn't reload, starting instead"
unicorn_rails $UNICORN_OPTS
;;
upgrade)
sig USR2 && exit 0
echo >&2 "Couldn't upgrade, starting instead"
unicorn_rails $UNICORN_OPTS
;;
rotate)
sig USR1 && echo rotated logs OK && exit 0
echo >&2 "Couldn't rotate logs" && exit 1
;;
*)
echo >&2 "Usage: $0 <start|stop|restart|upgrade|rotate|force-stop>"
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment