diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-08-23 17:39:53 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-08-23 17:42:50 -0700 |
commit | e9da4ce4c8917934242037db0c2735bd7dab1586 (patch) | |
tree | 6ae5903b532dfff07e88c7d32e329f069e417755 /lib/unicorn | |
parent | 8d8b500816371fb8f8fce5e9f21cf235ee8d26ae (diff) | |
download | unicorn-e9da4ce4c8917934242037db0c2735bd7dab1586.tar.gz |
I've noticed in stderr logs from some folks that (last resort) timeouts from the master process are taking too long to activate due to the workarounds for suspend/hibernation.
Diffstat (limited to 'lib/unicorn')
-rw-r--r-- | lib/unicorn/http_server.rb | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/unicorn/http_server.rb b/lib/unicorn/http_server.rb index 4f516c9..1d51001 100644 --- a/lib/unicorn/http_server.rb +++ b/lib/unicorn/http_server.rb @@ -264,8 +264,8 @@ class Unicorn::HttpServer if (last_check + @timeout) >= (last_check = Time.now) sleep_time = murder_lazy_workers else - # wait for workers to wakeup on suspend sleep_time = @timeout/2.0 + 1 + @logger.debug("waiting #{sleep_time}s after suspend/hibernation") end maintain_worker_count if respawn master_sleep(sleep_time) @@ -441,23 +441,23 @@ class Unicorn::HttpServer # forcibly terminate all workers that haven't checked in in timeout seconds. The timeout is implemented using an unlinked File def murder_lazy_workers - t = @timeout - next_sleep = 1 + next_sleep = @timeout - 1 now = Time.now.to_i WORKERS.dup.each_pair do |wpid, worker| tick = worker.tick 0 == tick and next # skip workers that are sleeping diff = now - tick - tmp = t - diff + tmp = @timeout - diff if tmp >= 0 - next_sleep < tmp and next_sleep = tmp + next_sleep > tmp and next_sleep = tmp next end + next_sleep = 0 logger.error "worker=#{worker.nr} PID:#{wpid} timeout " \ - "(#{diff}s > #{t}s), killing" + "(#{diff}s > #{@timeout}s), killing" kill_worker(:KILL, wpid) # take no prisoners for timeout violations end - next_sleep + next_sleep <= 0 ? 1 : next_sleep end def after_fork_internal |