class Ec2Templater::Monitor
Public Class Methods
new(command, interval)
click to toggle source
# File lib/ec2_templater/monitor.rb, line 3 def initialize(command, interval) @command = command @interval = interval end
Public Instance Methods
run() { |command_result| ... }
click to toggle source
# File lib/ec2_templater/monitor.rb, line 8 def run Ec2Templater.logger.info 'Monitoring' setup_signal_handlers loop do command_result = @command.call if command_result.changed? Ec2Templater.logger.info 'Notifying change' yield(command_result) end sleep @interval end end
setup_signal_handlers()
click to toggle source
# File lib/ec2_templater/monitor.rb, line 21 def setup_signal_handlers %w(INT TERM).each do |signal| trap signal do Ec2Templater.logger.info "Recieved SIG#{signal}, shutting down." exit 0 end end end