Class: Tailer::Listener
- Inherits:
-
Object
- Object
- Tailer::Listener
- Defined in:
- lib/tailer/listener.rb
Instance Attribute Summary collapse
-
#files ⇒ Object
Returns the value of attribute files.
-
#hosts ⇒ Object
Returns the value of attribute hosts.
-
#log ⇒ Object
Returns the value of attribute log.
-
#output ⇒ Object
Returns the value of attribute output.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(options) ⇒ Listener
constructor
A new instance of Listener.
- #spawn(host) ⇒ Object
Constructor Details
Instance Attribute Details
#files ⇒ Object
Returns the value of attribute files.
26 27 28 |
# File 'lib/tailer/listener.rb', line 26 def files @files end |
#hosts ⇒ Object
Returns the value of attribute hosts.
26 27 28 |
# File 'lib/tailer/listener.rb', line 26 def hosts @hosts end |
#log ⇒ Object
Returns the value of attribute log.
26 27 28 |
# File 'lib/tailer/listener.rb', line 26 def log @log end |
#output ⇒ Object
Returns the value of attribute output.
26 27 28 |
# File 'lib/tailer/listener.rb', line 26 def output @output end |
Instance Method Details
#execute ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# 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) ⇒ Object
36 37 38 |
# 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 |