Sha256: 14dbbf91d4bfe67a2efc94e48faf49e2a1bd96a2533297e5386545b6a96946e8

Contents?: true

Size: 909 Bytes

Versions: 19

Compression:

Stored size: 909 Bytes

Contents

module Refinery #:nodoc:
  # A heartbeat publisher that indicates a server is alive.
  class Heartbeat
    include Refinery::Loggable
    include Refinery::Configurable
    include Refinery::Queueable
    include Refinery::Utilities
    
    # Initialize the heartbeat for the given server.
    def initialize(server)
      @server = server
      @thread = Thread.new(queue('heartbeat')) do |heartbeat_queue|
        loop do
          begin
            logger.debug "Send heartbeat"
            message = {
              'host_info' => host_info,
              'timestamp' => Time.now.utc,
              'running_daemons' => @server.daemons.length
            }
            heartbeat_queue.send_message(Base64.encode64(message.to_json))
            sleep(60)
          rescue Exception => e
            logger.error "Error sending heartbeat: #{e.message}"
          end
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
aeden-refinery-0.9.1 lib/refinery/heartbeat.rb
aeden-refinery-0.9.10 lib/refinery/heartbeat.rb
aeden-refinery-0.9.2 lib/refinery/heartbeat.rb
aeden-refinery-0.9.4 lib/refinery/heartbeat.rb
aeden-refinery-0.9.5 lib/refinery/heartbeat.rb
aeden-refinery-0.9.6 lib/refinery/heartbeat.rb
aeden-refinery-0.9.7 lib/refinery/heartbeat.rb
aeden-refinery-0.9.8 lib/refinery/heartbeat.rb
aeden-refinery-0.9.9 lib/refinery/heartbeat.rb
refinery-0.9.3 lib/refinery/heartbeat.rb
refinery-0.9.4 lib/refinery/heartbeat.rb
refinery-0.9.5 lib/refinery/heartbeat.rb
refinery-0.9.6 lib/refinery/heartbeat.rb
refinery-0.9.7 lib/refinery/heartbeat.rb
refinery-0.9.8 lib/refinery/heartbeat.rb
refinery-0.9.9 lib/refinery/heartbeat.rb
refinery-0.9.10 lib/refinery/heartbeat.rb
refinery-0.9.0 lib/refinery/heartbeat.rb
refinery-0.9.2 lib/refinery/heartbeat.rb