about summary refs log tree commit homepage
path: root/lib/yahns/server_mp.rb
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2013-10-26 02:45:49 +0000
committerEric Wong <e@80x24.org>2013-10-26 02:45:49 +0000
commit50b9493b07023a8d6502e620657fa209b6aa74ef (patch)
treed191cf061b5bd7b24f28209da170acebde614e65 /lib/yahns/server_mp.rb
parent5d5377e094745ee76cd066d2244c52b40647d1cc (diff)
downloadyahns-50b9493b07023a8d6502e620657fa209b6aa74ef.tar.gz
We'll hit SIGCHLD if our reexec process fails on us, so the
non-MP server must handle it, too.  We discovered this bug
while porting the PID file renaming changes from unicorn.
Diffstat (limited to 'lib/yahns/server_mp.rb')
-rw-r--r--lib/yahns/server_mp.rb27
1 files changed, 1 insertions, 26 deletions
diff --git a/lib/yahns/server_mp.rb b/lib/yahns/server_mp.rb
index 640f1b2..c8e1989 100644
--- a/lib/yahns/server_mp.rb
+++ b/lib/yahns/server_mp.rb
@@ -4,31 +4,6 @@
 module Yahns::ServerMP # :nodoc:
   EXIT_SIGS = [ :QUIT, :TERM, :INT ]
 
-  def mp_init
-    trap(:CHLD) { @sev.sev_signal }
-  end
-
-  # reaps all unreaped workers
-  def reap_all_workers
-    begin
-      wpid, status = Process.waitpid2(-1, Process::WNOHANG)
-      wpid or return
-      if @reexec_pid == wpid
-        @logger.error "reaped #{status.inspect} exec()-ed"
-        @reexec_pid = 0
-        self.pid = @pid.chomp('.oldbin') if @pid
-        proc_name 'master'
-      else
-        worker = @workers.delete(wpid)
-        worker_id = worker ? worker.nr : "(unknown)"
-        m = "reaped #{status.inspect} worker=#{worker_id}"
-        status.success? ? @logger.info(m) : @logger.error(m)
-      end
-    rescue Errno::ECHILD
-      return
-    end while true
-  end
-
   def maintain_worker_count
     (off = @workers.size - @worker_processes) == 0 and return
     off < 0 and return spawn_missing_workers
@@ -111,7 +86,7 @@ module Yahns::ServerMP # :nodoc:
     begin
       @sev.kgio_wait_readable
       @sev.yahns_step
-      reap_all_workers
+      reap_all
       case @sig_queue.shift
       when *EXIT_SIGS # graceful shutdown (twice for non graceful)
         @listeners.each(&:close).clear