Class: Spanx::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/spanx/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Runner

Returns a new instance of Runner.



28
29
30
31
32
33
34
35
36
37
# File 'lib/spanx/runner.rb', line 28

def initialize(*args)
  @config = args.last.is_a?(Hash) ? args.pop : {}
  @queue = Queue.new
  validate_args!(args)
  @actors = args.map { |actor| self.send(actor.to_sym) }

  Daemonize.daemonize if config[:daemonize]

  STDOUT.sync = true if config[:debug]
end

Instance Attribute Details

#actorsObject

Returns the value of attribute actors.



26
27
28
# File 'lib/spanx/runner.rb', line 26

def actors
  @actors
end

#configObject

Returns the value of attribute config.



26
27
28
# File 'lib/spanx/runner.rb', line 26

def config
  @config
end

#queueObject

Returns the value of attribute queue.



26
27
28
# File 'lib/spanx/runner.rb', line 26

def queue
  @queue
end

Instance Method Details

#analyzerObject



58
59
60
# File 'lib/spanx/runner.rb', line 58

def analyzer
  @analyzer ||= Spanx::Actor::Analyzer.new(config)
end

#collectorObject

actors



46
47
48
# File 'lib/spanx/runner.rb', line 46

def collector
  @collector ||= Spanx::Actor::Collector.new(config, queue)
end

#log_readerObject



50
51
52
# File 'lib/spanx/runner.rb', line 50

def log_reader
  @log_reader ||= Spanx::Actor::LogReader.new(config[:access_log], queue, config[:log_reader][:tail_interval], whitelist)
end

#runObject



39
40
41
42
# File 'lib/spanx/runner.rb', line 39

def run
  threads = actors.map(&:run)
  threads.last.join
end

#whitelistObject

helpers



64
65
66
# File 'lib/spanx/runner.rb', line 64

def whitelist
  @whitelist ||= Spanx::Whitelist.new(config[:whitelist_file])
end

#writerObject



54
55
56
# File 'lib/spanx/runner.rb', line 54

def writer
  @writer ||= Spanx::Actor::Writer.new(config)
end