From c0813d5c3307082dcc73a930e2de218aab8be235 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 9 Nov 2009 15:17:02 -0800 Subject: don't nuke children for long after_fork and app loads Sometimes app loads and after_fork hooks can take a long time, even longer than shorter timeouts. Since timeouts are only meant for application processing when clients are involved, we won't nuke workers that have never chmodded before. --- lib/unicorn.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/unicorn.rb b/lib/unicorn.rb index 0f2b597..7fa8468 100644 --- a/lib/unicorn.rb +++ b/lib/unicorn.rb @@ -507,7 +507,10 @@ module Unicorn # worker. def murder_lazy_workers WORKERS.dup.each_pair do |wpid, worker| - (diff = (Time.now - worker.tmp.stat.ctime)) <= timeout and next + stat = worker.tmp.stat + # skip workers that disable fchmod or have never fchmod-ed + stat.mode == 0100600 and next + (diff = (Time.now - stat.ctime)) <= timeout and next logger.error "worker=#{worker.nr} PID:#{wpid} timeout " \ "(#{diff}s > #{timeout}s), killing" kill_worker(:KILL, wpid) # take no prisoners for timeout violations -- cgit v1.2.3-24-ge0c7