Class: Fluent::ConfigReloaderOutput

Inherits:
MultiOutput
  • Object
show all
Defined in:
lib/fluent/plugin/out_config_reloader.rb

Defined Under Namespace

Classes: ReloadFileWatcher

Instance Method Summary collapse

Constructor Details

#initializeConfigReloaderOutput

Returns a new instance of ConfigReloaderOutput.



40
41
42
43
44
# File 'lib/fluent/plugin/out_config_reloader.rb', line 40

def initialize
  super

  @q = Queue.new
end

Instance Method Details

#configure(conf) ⇒ Object



50
51
52
53
54
# File 'lib/fluent/plugin/out_config_reloader.rb', line 50

def configure(conf)
  super
 
  load_config_file
end

#emit(tag, es, chain) ⇒ Object



74
75
76
77
78
79
80
81
# File 'lib/fluent/plugin/out_config_reloader.rb', line 74

def emit(tag, es, chain)
  param = OpenStruct.new
  param.tag = tag
  param.es = es
  param.chain = chain
 
  @q.push param
end

#outputsObject



46
47
48
# File 'lib/fluent/plugin/out_config_reloader.rb', line 46

def outputs
  [@output]
end

#shutdownObject



66
67
68
69
70
71
72
# File 'lib/fluent/plugin/out_config_reloader.rb', line 66

def shutdown
  @watcher.delete_observers
  Thread.kill(@thread) 
  output_shutdown
rescue
  $log.warn "raises exception: #{$!.class}, '#{$!.message}"
end

#startObject



56
57
58
59
60
61
62
63
64
# File 'lib/fluent/plugin/out_config_reloader.rb', line 56

def start
  output_start
  @thread = Thread.new(&method(:run))
  
  @watcher = ReloadFileWatcher.create(self, @reload_file, @reload_file_watch_interval)
  
rescue
  $log.warn "raises exception: #{$!.class}, '#{$!.message}"
end

#updateObject



83
84
85
86
87
88
89
# File 'lib/fluent/plugin/out_config_reloader.rb', line 83

def update
  $log.warn 'config_reloader: reload config file start'
  output_shutdown
  load_config_file
  output_start
  $log.warn 'config_reloader: reload config file end'
end