Last active
August 29, 2015 14:28
-
-
Save atuyosi/f02d16932e2f9125967a to your computer and use it in GitHub Desktop.
This file contains 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
!/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