From 225a108c5326fdc1a00531908a2278c06ac782f6 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 13 Feb 2009 21:02:10 -0800 Subject: trap SIGCHLD and wakeup master on it And avoid repeatedly sending kill -0 to each worker, that nugget of stupid probably slipped in while I was testing something... --- lib/unicorn.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/unicorn.rb b/lib/unicorn.rb index 63d7f5c..df94a96 100644 --- a/lib/unicorn.rb +++ b/lib/unicorn.rb @@ -159,14 +159,13 @@ module Unicorn @rd_sig, @wr_sig = IO.pipe unless (@rd_sig && @wr_sig) @rd_sig.nonblock = @wr_sig.nonblock = true - %w(QUIT INT TERM USR1 USR2 HUP).each { |sig| trap_deferred(sig) } + %w(CHLD QUIT INT TERM USR1 USR2 HUP).each { |sig| trap_deferred(sig) } $0 = "unicorn master" begin loop do reap_all_workers case @mode when :idle - kill_each_worker(0) # ensure they're running murder_lazy_workers spawn_missing_workers when 'QUIT' # graceful shutdown @@ -376,6 +375,7 @@ module Unicorn # by the user. def init_worker_process(worker) %w(TERM INT QUIT USR1 USR2 HUP).each { |sig| trap(sig, 'IGNORE') } + trap('CHLD', 'DEFAULT') $0 = "unicorn worker[#{worker.nr}]" @rd_sig.close if @rd_sig @wr_sig.close if @wr_sig -- cgit v1.2.3-24-ge0c7