Sha256: 4dfad5f35f89b8fc8be389c9d0d3b9d789e0b6d011723ada6191df5f325c1721
Contents?: true
Size: 1.45 KB
Versions: 5
Compression:
Stored size: 1.45 KB
Contents
#!/bin/sh set -u TIMEOUT=${TIMEOUT-60} RBENV_ROOT="{{ rbenv_root }}" PATH="$RBENV_ROOT/bin:$RBENV_ROOT/shims:$PATH" APP_ROOT="{{be_app_path}}" APP_USER="{{ deployer_user.name }}" PID="$APP_ROOT/tmp/unicorn/unicorn.pid" CMD="bundle exec unicorn -E {{be_app_env}} -D -c $APP_ROOT/config/unicorn.rb" action="$1" 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 $action in start) sig 0 && echo >&2 "Already running" && exit 0 rm -f $PID && $CMD ;; stop) sig QUIT && echo "Stopping" && exit 0 echo >&2 "Unicorn master process with ID `cat $PID` not found (see: $PID)" ;; force-stop) pkill -9 -f "unicorn master" && echo "Forcing a stop\n" && rm -f $PID && echo "Cleaning up pid" && exit 0 ;; restart|reload) sig HUP && echo reloaded OK && exit 0 echo >&2 "Couldn't reload, starting '$CMD' instead" $CMD ;; upgrade) if sig USR2 && sleep 2 && sig 0 && oldsig QUIT then n=$TIMEOUT while test -s $old_pid && test $n -ge 0 do printf '.' && sleep 1 && n=$(( $n - 1 )) done echo if test $n -lt 0 && test -s $old_pid then echo >&2 "$old_pid still exists after $TIMEOUT seconds" exit 1 fi exit 0 fi echo >&2 "Couldn't upgrade, starting '$CMD' instead" $CMD ;; reopen-logs) sig USR1 ;; *) echo >&2 "Usage: $0 <start|stop|restart|upgrade|force-stop|reopen-logs>" exit 1 ;; esac
Version data entries
5 entries across 5 versions & 1 rubygems