Class: NodeHeartbeat::RunHeartbeat
- Defined in:
- lib/node_heartbeat/run_heartbeat.rb
Constant Summary collapse
- SLEEP_TIME =
1 hour
60 * 60
- ERROR_SLEEP_TIME =
5
Instance Attribute Summary collapse
-
#bucket ⇒ Object
Returns the value of attribute bucket.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(bucket:) ⇒ RunHeartbeat
constructor
A new instance of RunHeartbeat.
Methods inherited from Base
Constructor Details
#initialize(bucket:) ⇒ RunHeartbeat
Returns a new instance of RunHeartbeat.
11 12 13 |
# File 'lib/node_heartbeat/run_heartbeat.rb', line 11 def initialize(bucket:) self.bucket = bucket end |
Instance Attribute Details
#bucket ⇒ Object
Returns the value of attribute bucket.
6 7 8 |
# File 'lib/node_heartbeat/run_heartbeat.rb', line 6 def bucket @bucket end |
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/node_heartbeat/run_heartbeat.rb', line 15 def call %w(INT TERM).each do |sig| begin trap sig do raise Interrupt end rescue ArgumentError puts "Signal #{sig} not supported" end end begin while true timeout = SLEEP_TIME begin BeatOnce.call(bucket: self.bucket) rescue => e puts "Warning: #{e.}" timeout = ERROR_SLEEP_TIME end sleep timeout end rescue Interrupt puts 'Exiting' end end |