From e93f84e28f0da4ce7aa21d714f0504677f4bf6f6 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 24 Apr 2009 01:21:31 -0700 Subject: Avoid getppid() if serving heavy traffic As long as our speculative accept()s are succeeding, then avoid checking for master process death and keep processing requests. This allows us to save some syscalls under extremely heavy traffic spikes. --- lib/unicorn.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/unicorn.rb b/lib/unicorn.rb index c2ac09d..a049b5c 100644 --- a/lib/unicorn.rb +++ b/lib/unicorn.rb @@ -471,7 +471,7 @@ module Unicorn [:TERM, :INT].each { |sig| trap(sig) { exit(0) } } # instant shutdown @logger.info "worker=#{worker.nr} ready" - while alive && master_pid == Process.ppid + while alive if nr < 0 @logger.info "worker=#{worker.nr} reopening logs..." Unicorn::Util.reopen_logs @@ -517,6 +517,7 @@ module Unicorn if nr != 0 # (nr < 0) => reopen logs ready = LISTENERS else + master_pid == Process.ppid or exit(0) begin alive.chmod(nr += 1) # timeout used so we can detect parent death: -- cgit v1.2.3-24-ge0c7