Created
July 21, 2013 09:35
-
-
Save bageljp/6048066 to your computer and use it in GitHub Desktop.
unicorn init script with rbenv and bundler.
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 | |
| # | |
| # unicorn | |
| # | |
| # chkconfig: - 80 20 | |
| # description: unicorn | |
| # processname: unicorn | |
| # config: /usr/local/redmine/config/unicorn.rb | |
| # pidfile: /usr/local/redmine/tmp/pids/.pid | |
| # Source function library. | |
| . /etc/rc.d/init.d/functions | |
| # Source networking configuration. | |
| . /etc/sysconfig/network | |
| # Check that networking is up. | |
| [ "$NETWORKING" = "no" ] && exit 0 | |
| prog="unicorn" | |
| RAILS_ROOT="/usr/local/redmine" | |
| lockfile="/var/lock/subsys/unicorn" | |
| pidfile="${RAILS_ROOT}/tmp/pids/unicorn.pid" | |
| CONF_FILE="${RAILS_ROOT}/config/unicorn.rb" | |
| CMD_BUNDLE="/root/.rbenv/shims/bundle" | |
| PATH="/usr/local/rbenv/bin:${PATH}" | |
| #eval "$(rbenv init -)" | |
| start() { | |
| [ -f $NGINX_CONF_FILE ] || exit 6 | |
| echo -n $"Starting $prog: " | |
| cd ${RAILS_ROOT} | |
| ${CMD_BUNDLE} exec unicorn_rails -c ${CONF_FILE} -E production -D --path /redmine | |
| retval=$? | |
| echo | |
| [ $retval -eq 0 ] && touch $lockfile | |
| return $retval | |
| } | |
| stop() { | |
| echo -n $"Stopping $prog: " | |
| killproc -p $pidfile $prog | |
| retval=$? | |
| echo | |
| [ $retval -eq 0 ] && rm -f $lockfile | |
| return $retval | |
| } | |
| restart() { | |
| stop | |
| start | |
| } | |
| case "$1" in | |
| start) | |
| $1 | |
| ;; | |
| stop) | |
| $1 | |
| ;; | |
| restart) | |
| $1 | |
| ;; | |
| *) | |
| echo $"Usage: $0 {start|stop|restart}" | |
| exit 2 | |
| esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment