Skip to content

Instantly share code, notes, and snippets.

@atuyosi
Last active August 29, 2015 14:28
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 atuyosi/f02d16932e2f9125967a to your computer and use it in GitHub Desktop.
Save atuyosi/f02d16932e2f9125967a to your computer and use it in GitHub Desktop.
!/sbin/runscript
set_unicornvars() {
UNICORN_PID="/var/lib/fastladder/tmp/pids/unicorn.pid"
UNICORN_CONF="/var/lib/fastladder/config/unicorn.rb"
FAST_HOME="/var/lib/fastladder"
}
extra_commands="depend"
extra_started_commands="reload"
depend() {
need net
use apache2 lighttpd nginx
}
start() {
ebegin "Starting FastLadder with unicorn"
set_unicornvars
start-stop-daemon --start --chdir ${FAST_HOME} --pidfile ${UNICORN_PID} --exec \
/usr/local/bin/unicorn_rails -- -c ${UNICORN_CONF} -E production -D
local i=0
local timeout=5
while [ ! -f ${UNICORN_PID} ] && [ $i -le $timeout ]; do
sleep 1
i=$(($i + 1))
done
[ $timeout -gt $i ]
eend $?
}
stop() {
ebegin "Stopping FastLadder by unicorn"
set_unicornvars
start-stop-daemon --signal QUIT --stop --pidfile ${UNICORN_PID}
eend $?
}
reload() {
ebegin "Reloading FastLadder by unicorn"
set_unicornvars
[ -f ${UNICORN_PID} ] && kill -USR2 $(cat ${PHP_FPM_PID})
eend $?
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment