class Metrux::Commands::PeriodicGauge::Supervisor
Constants
- INTERVAL_CHECK
Attributes
agent[R]
Public Class Methods
new(agent, config)
click to toggle source
# File lib/metrux/commands/periodic_gauge/supervisor.rb, line 10 def initialize(agent, config) @agent = agent @logger = config.logger @thread = nil end
Public Instance Methods
alive?()
click to toggle source
# File lib/metrux/commands/periodic_gauge/supervisor.rb, line 32 def alive? @thread && @thread.alive? end
start()
click to toggle source
# File lib/metrux/commands/periodic_gauge/supervisor.rb, line 16 def start unless alive? log('Starting...', :info) @thread = Thread.new { loop { check } } return true end false end
stop()
click to toggle source
# File lib/metrux/commands/periodic_gauge/supervisor.rb, line 26 def stop log('Stopping...', :info) @thread.kill if @thread @thread = nil end
Private Instance Methods
check()
click to toggle source
# File lib/metrux/commands/periodic_gauge/supervisor.rb, line 40 def check wait(INTERVAL_CHECK) unless agent.alive? log('Agent is dead. Restarting...', :info) agent.start end rescue => e log("ERROR: #{e.class}: #{e.message}", :error) end