Sha256: 27f89839b9a306a8014af30072653eb0d63ed6aeadb2d55a6fb6aae9be371fc6
Contents?: true
Size: 1.71 KB
Versions: 1
Compression:
Stored size: 1.71 KB
Contents
require 'logger' require 'tempfile' require 'jrjackson' require_relative 'mjolnir' require_relative 'metadata' require_relative 'input' require_relative 'filter' require_relative 'output' module Anschel class Main < Mjolnir desc 'version', 'Echo the application version' def version puts VERSION end desc 'art', 'View the application art' def art puts "\n%s\n" % ART end desc 'agent', 'Run the Anschel agent' option :config, \ type: :string, aliases: %w[ -c ], desc: 'Main configuration file', default: '/etc/anschel.json' include_common_options def agent log.info event: 'hello' config = JrJackson::Json.load File.read(options.config), symbolize_keys: true setup_log4j config[:log4j] input = Input.new config[:kafka], log filter = Filter.new config[:filter], log output = Output.new config[:elasticsearch], log start = Time.now count = 0 sample = 100_000 ts = num_cpus.times.map do Thread.new do loop do event = JrJackson::Json.load \ input.shift.message.to_s, symbolize_keys: true output.push filter.apply(event) if (count += 1) % sample == 0 old_count, now = count, Time.now elapsed, start = (now - start).to_f, now rate = 1.0 * sample / elapsed log.info \ event: 'stat', count: old_count, sample: sample, elapsed_s: elapsed, rate_eps: rate end end end end log.info event: 'fully-loaded' ts.map &:join exit end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
anschel-0.1.0 | lib/anschel/main.rb |