1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00
This commit is contained in:
Seamus Abshere 2012-06-27 11:26:19 -05:00
parent 83bdf72acc
commit 7e032cc6ad

View file

@ -42,47 +42,10 @@ signal_worker() {
if [ -f $PID_FILE ]; then
set_pid_from_file
logger -t "monit-sidekiq[$$]" "Issuing kill with -$SIG $PID"
SLEEP_COUNT=0
kill -$SIG $PID
fi
}
signal_worker_fatally(){
signal_worker()
if [ -f $PID_FILE ]; then
if [ -n "$ALLOW_TIMEOUT" ]; then
while [ -e /proc/$PID ]; do
sleep .25
let "SLEEP_COUNT+=1"
let "REPORT_TIME = $SLEEP_COUNT%4"
if(( "$SLEEP_COUNT" > $GRACE_TIME )); then
logger -t "monit-sidekiq[$$]" "Sidekiq worker with pid $PID for $WORKER_REF still running, issuing -TERM"
kill -15 $PID 2>/dev/null; true
elif(( $REPORT_TIME == 0 )); then
let "RUNTIME = $SLEEP_COUNT/4"
logger -t "monit-sidekiq[$$]" "waiting for $PID to die ( for $RUNTIME seconds now)"
fi
done
fi
sleep 1
if [ -d /proc/$PID ];then
for child in $(ps axo pid,ppid | awk "{ if ( \$2 == $PID ) { print \$1 }}");
do
kill -9 $child 2>/dev/null; true
logger -t "monit-sidekiq[$$]" "Murdering Sidekiq workers child with $child for $WORKER_REF"
break
done
while [ -d /proc/$PID ]; do
logger -t "monit-sidekiq[$$]" "Murdering Sidekiq worker with $PID for $WORKER_REF"
kill -9 $PID
sleep 1
done
fi
logger -t "monit-sidekiq[$$]" "Removing pid file for $PID - $WORKER_REF"
[ -e "$PID_FILE" -a ! -d /proc/$PID ] && rm -f $PID_FILE
fi
}
lock(){
RESULT=0
if [ -e $LOCK_FILE ]; then
@ -201,8 +164,6 @@ if [ -d $APP_ROOT ]; then
legacy_fix
lock
SIG="INT"
[ -z "$GRACE_TIME" ] && GRACE_TIME=60
ALLOW_TIMEOUT=1
signal_worker
[ -e "$LOCK_FILE" ] && rm $LOCK_FILE
unlock_and_exit_cleanly