From e4d0b226391948ef433f1d0135814315e4c48535 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 7 Aug 2010 04:25:51 +0000 Subject: log ERROR messages if workers exit with failure Something is wrong if workers exit with a non-zero status, so we'll increase the log level to help prevent people from missing it. --- lib/unicorn.rb | 4 ++-- t/t0010-reap-logging.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 2 deletions(-) create mode 100755 t/t0010-reap-logging.sh diff --git a/lib/unicorn.rb b/lib/unicorn.rb index 8f490bb..52349f0 100644 --- a/lib/unicorn.rb +++ b/lib/unicorn.rb @@ -519,8 +519,8 @@ module Unicorn proc_name 'master' else worker = WORKERS.delete(wpid) and worker.tmp.close rescue nil - logger.info "reaped #{status.inspect} " \ - "worker=#{worker.nr rescue 'unknown'}" + m = "reaped #{status.inspect} worker=#{worker.nr rescue 'unknown'}" + status.success? ? logger.info(m) : logger.error(m) end end rescue Errno::ECHILD diff --git a/t/t0010-reap-logging.sh b/t/t0010-reap-logging.sh new file mode 100755 index 0000000..93d8c60 --- /dev/null +++ b/t/t0010-reap-logging.sh @@ -0,0 +1,55 @@ +#!/bin/sh +. ./test-lib.sh +t_plan 9 "reap worker logging messages" + +t_begin "setup and start" && { + unicorn_setup + cat >> $unicorn_config < $r_err +} + +t_begin "kill 2nd worker gracefully" && { + pid_2=$(curl http://$listen/) + kill -QUIT $pid_2 +} + +t_begin "wait for 3rd worker=0 to start " && { + test '.' = $(cat $fifo) +} + +t_begin "ensure log of 2nd reap is a INFO" && { + grep 'INFO.*reaped.*worker=0' $r_err | grep $pid_2 + > $r_err +} + +t_begin "killing succeeds" && { + kill $unicorn_pid + wait + kill -0 $unicorn_pid && false +} + +t_begin "check stderr" && { + check_stderr +} + +t_done -- cgit v1.2.3-24-ge0c7