class Tailer::Listener
Attributes
files[RW]
hosts[RW]
log[RW]
output[RW]
Public Class Methods
new(options)
click to toggle source
# File lib/tailer/listener.rb, line 27 def initialize(options) @hosts = options[:hosts] @files = options[:files] @log = options[:log] || ::Logger.new(STDERR) Handler.output = options[:output] || STDOUT Handler.log = log @last_status = 0 end
Public Instance Methods
execute()
click to toggle source
# File lib/tailer/listener.rb, line 40 def execute begin @t_start = Time.now.to_f Handler.t_start = Time.now.to_f Handler.bytes = 0 Handler.last_status = 0 EventMachine.run do @hosts.each do |host| spawn(host) end end rescue Errno::EPIPE => e @log.info "Exiting..." rescue Interrupt => e @log.info "Exiting..." end end
spawn(host)
click to toggle source
# File lib/tailer/listener.rb, line 36 def spawn(host) EventMachine.popen("ssh #{Shellwords.escape(host)} \"tail -q -F #{@files.map { |file| Shellwords.escape(file) }.join(' ')}\"", Handler) end