Class: Refinery::Heartbeat
- Inherits:
-
Object
- Object
- Refinery::Heartbeat
- Includes:
- Configurable, Loggable, Queueable, Utilities
- Defined in:
- lib/refinery/heartbeat.rb
Overview
A heartbeat publisher that indicates a server is alive.
Instance Method Summary collapse
-
#initialize(server) ⇒ Heartbeat
constructor
Initialize the heartbeat for the given server.
Methods included from Utilities
#camelize, #decode_message, #encode_message, #host_info
Methods included from Queueable
Methods included from Configurable
Methods included from Loggable
Constructor Details
#initialize(server) ⇒ Heartbeat
Initialize the heartbeat for the given server.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/refinery/heartbeat.rb', line 10 def initialize(server) queue_prefix = config['prefix'] || '' @server = server @thread = Thread.new do begin require 'java' java.lang.Thread.current_thread.name = 'Heartbeat' rescue Exception => e end loop do with_queue("#{queue_prefix}heartbeat") do |heartbeat_queue| logger.debug "Send heartbeat" = { 'host_info' => host_info, 'timestamp' => Time.now.utc, 'running_daemons' => @server.daemons.length } heartbeat_queue.(Base64.encode64(.to_json)) sleep(60) end end end end |