diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-12-26 03:29:16 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-12-26 03:29:16 +0000 |
commit | 17156f6f561c6d697a83e3b9beae2d58eb796428 (patch) | |
tree | 14c02ce893cc15e2f72b2e2a1ea8d9d4a89ff328 /lib/rainbows/rev/heartbeat.rb | |
parent | 68accc9930b0653b702553790d4ccd626a8dfdfe (diff) | |
download | rainbows-17156f6f561c6d697a83e3b9beae2d58eb796428.tar.gz |
This makes constant resolution more predictable, we hope.
Diffstat (limited to 'lib/rainbows/rev/heartbeat.rb')
-rw-r--r-- | lib/rainbows/rev/heartbeat.rb | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/lib/rainbows/rev/heartbeat.rb b/lib/rainbows/rev/heartbeat.rb index f348a08..c4a9bb9 100644 --- a/lib/rainbows/rev/heartbeat.rb +++ b/lib/rainbows/rev/heartbeat.rb @@ -1,23 +1,20 @@ # -*- encoding: binary -*- # :enddoc: -module Rainbows - module Rev - - # This class handles the Unicorn fchmod heartbeat mechanism - # in Rev-based concurrency models to prevent the master - # process from killing us unless we're blocked. This class - # will also detect and execute the graceful exit if triggered - # by SIGQUIT - class Heartbeat < ::Rev::TimerWatcher - - def on_timer - if (ot = G.kato) >= 0 - ot = Time.now - ot - KATO.delete_if { |client, time| time < ot and client.timeout? } - end - exit if (! G.tick && CONN.size <= 0) - end +# This class handles the Unicorn fchmod heartbeat mechanism +# in Rev-based concurrency models to prevent the master +# process from killing us unless we're blocked. This class +# will also detect and execute the graceful exit if triggered +# by SIGQUIT +class Rainbows::Rev::Heartbeat < Rev::TimerWatcher + KATO = Rainbows::Rev::KATO + CONN = Rainbows::Rev::CONN + G = Rainbows::G + def on_timer + if (ot = G.kato) >= 0 + ot = Time.now - ot + KATO.delete_if { |client, time| time < ot and client.timeout? } end + exit if (! G.tick && CONN.size <= 0) end end |