rainbows.git  about / heads / tags
Unicorn for sleepy apps and slow clients
blob f348a08caeccddaad388239082d853870595c08a 620 bytes (raw)
$ git show v0.97.0:lib/rainbows/rev/heartbeat.rb	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 
# -*- 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

    end
  end
end

git clone https://yhbt.net/rainbows.git