class Fluent::EventSniffer

Public Instance Methods

shutdown() click to toggle source
Calls superclass method
# File lib/fluent/plugin/in_event_sniffer.rb, line 44
def shutdown
  super

  if @srv
    @srv.stop
    @srv = nil
  end

  if @access_log and (not @access_log.closed?)
    @access_log.close
  end

  if @thread
    @thread.join
    @thread = nil
  end
end
start() click to toggle source
Calls superclass method
# File lib/fluent/plugin/in_event_sniffer.rb, line 17
def start
  super

  $log.info "listening http server for event_sniffer on http://#{@bind}:#{@port}"

  @access_log = File.open(@access_log_path, 'a') if @access_log_path

  config = {
    development: @development,
  }
  app = Rack::Builder.new do
    ENV['RACK_ENV'] = config[:development] ? 'development' : 'production'
    require_relative 'eventsniffer/app'
    run EventSnifferPlugin::App.new
  end

  EventSnifferPlugin::App.set :pattern_bookmarks, @pattern_bookmarks
  EventSnifferPlugin::App.set :max_events, @max_events
  EventSnifferPlugin::App.set :refresh_interval, @refresh_interval

  options = {
    signals: false,
  }
  @srv = ::Thin::Server.new(@bind, @port, app, options)
  @thread = Thread.new { @srv.start }
end