Class: Dexter::Processor
- Inherits:
-
Object
- Object
- Dexter::Processor
- Includes:
- Logging
- Defined in:
- lib/dexter/processor.rb
Instance Method Summary collapse
-
#initialize(logfile, options) ⇒ Processor
constructor
A new instance of Processor.
- #perform ⇒ Object
Methods included from Logging
Constructor Details
#initialize(logfile, options) ⇒ Processor
Returns a new instance of Processor.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/dexter/processor.rb', line 5 def initialize(logfile, ) @logfile = logfile @collector = Collector.new(min_time: [:min_time]) @log_parser = LogParser.new(logfile, @collector) @indexer = Indexer.new() @starting_interval = 3 @interval = [:interval] @mutex = Mutex.new @last_checked_at = {} log "Started" end |
Instance Method Details
#perform ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/dexter/processor.rb', line 21 def perform if @logfile == STDIN Thread.abort_on_exception = true Thread.new do sleep(@starting_interval) loop do begin process_queries rescue PG::ServerError => e log "ERROR: #{e.class.name}: #{e.message}" end sleep(@interval) end end end begin @log_parser.perform rescue Errno::ENOENT => e abort e. end process_queries end |