about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-04-17 07:43:57 -0700
committerEric Wong <normalperson@yhbt.net>2010-04-19 01:37:53 -0700
commit5dd4c12411b5567fb340e897d0b544dfff7fa7a2 (patch)
treee98c98978ae2d0aa595bbc5dd88f783539ff19fe /lib
parent900628706d6ced43fde614a6fc57f2d2d69e945d (diff)
downloadunicorn-5dd4c12411b5567fb340e897d0b544dfff7fa7a2.tar.gz
Trying to fix this issue again, as it seems to have been broken
again.
Diffstat (limited to 'lib')
-rw-r--r--lib/unicorn.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/unicorn.rb b/lib/unicorn.rb
index 4fbddc8..72cda10 100644
--- a/lib/unicorn.rb
+++ b/lib/unicorn.rb
@@ -402,9 +402,12 @@ module Unicorn
             # machine) comes out of suspend/hibernation
             if (last_check + timeout) >= (last_check = Time.now)
               murder_lazy_workers
+            else
+              # wait for workers to wakeup on suspend
+              master_sleep(timeout/2.0 + 1)
             end
             maintain_worker_count if respawn
-            master_sleep
+            master_sleep(1)
           when :QUIT # graceful shutdown
             break
           when :TERM, :INT # immediate shutdown
@@ -485,9 +488,9 @@ module Unicorn
 
     # wait for a signal hander to wake us up and then consume the pipe
     # Wake up every second anyways to run murder_lazy_workers
-    def master_sleep
+    def master_sleep(sec)
       begin
-        ready = IO.select([SELF_PIPE.first], nil, nil, 1) or return
+        ready = IO.select([SELF_PIPE.first], nil, nil, sec) or return
         ready.first && ready.first.first or return
         loop { SELF_PIPE.first.read_nonblock(Const::CHUNK_SIZE) }
       rescue Errno::EAGAIN, Errno::EINTR