Class: Turnstile::Collector::Runner
- Inherits:
-
Object
- Object
- Turnstile::Collector::Runner
- Defined in:
- lib/turnstile/collector/runner.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#file ⇒ Object
Returns the value of attribute file.
-
#queue ⇒ Object
Returns the value of attribute queue.
-
#reader ⇒ Object
Returns the value of attribute reader.
-
#updater ⇒ Object
Returns the value of attribute updater.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Runner
constructor
A new instance of Runner.
- #log_reader_class ⇒ Object
- #run ⇒ Object
- #wait_for_file(file) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Runner
Returns a new instance of Runner.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/turnstile/collector/runner.rb', line 11 def initialize(*args) @config = args.last.is_a?(Hash) ? args.pop : {} @file = config[:file] @queue = Queue.new config[:debug] ? Turnstile::Logger.enable : Turnstile::Logger.disable wait_for_file(@file) self.reader self.updater Daemonize.daemonize if config[:daemonize] STDOUT.sync = true if config[:debug] end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
9 10 11 |
# File 'lib/turnstile/collector/runner.rb', line 9 def config @config end |
#file ⇒ Object
Returns the value of attribute file.
9 10 11 |
# File 'lib/turnstile/collector/runner.rb', line 9 def file @file end |
#queue ⇒ Object
Returns the value of attribute queue.
9 10 11 |
# File 'lib/turnstile/collector/runner.rb', line 9 def queue @queue end |
#reader ⇒ Object
Returns the value of attribute reader.
9 10 11 |
# File 'lib/turnstile/collector/runner.rb', line 9 def reader @reader end |
#updater ⇒ Object
Returns the value of attribute updater.
9 10 11 |
# File 'lib/turnstile/collector/runner.rb', line 9 def updater @updater end |
Instance Method Details
#log_reader_class ⇒ Object
49 50 51 |
# File 'lib/turnstile/collector/runner.rb', line 49 def log_reader_class Turnstile::Collector::LogReader end |
#run ⇒ Object
38 39 40 41 |
# File 'lib/turnstile/collector/runner.rb', line 38 def run threads = [reader, updater].map(&:run) threads.last.join end |
#wait_for_file(file) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/turnstile/collector/runner.rb', line 27 def wait_for_file(file) sleep_period = 1 while !File.exist?(file) STDERR.puts "File #{file.bold.yellow} does not exist, waiting for it to appear..." STDERR.puts 'Press Ctrl-C to abort.' if sleep_period == 1 sleep sleep_period sleep_period *= 1.2 end end |