Class: Fluent::EventSniffer

Inherits:
Input
  • Object
show all
Defined in:
lib/fluent/plugin/in_event_sniffer.rb

Instance Method Summary collapse

Instance Method Details

#shutdownObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# 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

#startObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# 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