Class: Fluent::JvmwatcherInput

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

Instance Method Summary collapse

Constructor Details

#initializeJvmwatcherInput

Returns a new instance of JvmwatcherInput.



9
10
11
12
13
14
15
# File 'lib/fluent/plugin/in_jvmwatcher.rb', line 9

def initialize
  super
  @log4j_path = JvmwatcherUtil.make_log4j_file
  @setenv_path = JvmwatcherUtil.make_setenv_file
  @bin_path = JvmwatcherUtil.find_watcher_java_path(JvmwatcherUtil::BinDirName)
  @jvmwatcher_connamd = File.join(@bin_path, "JvmWatcher.sh")
end

Instance Method Details

#runObject



41
42
43
# File 'lib/fluent/plugin/in_jvmwatcher.rb', line 41

def run
  @io.each_line(&method(:each_line))
end

#shutdownObject



32
33
34
35
36
37
38
39
# File 'lib/fluent/plugin/in_jvmwatcher.rb', line 32

def shutdown
  Process.kill(:TERM, @pid)
  if @thread.join(60)
    return
  end
  Process.kill(:KILL, @pid)
  @yhread.join
end

#startObject



23
24
25
26
27
28
29
30
# File 'lib/fluent/plugin/in_jvmwatcher.rb', line 23

def start
  @config_path = JvmwatcherUtil.find_filter_config_path(@filter_config_path)
  command = "#{@jvmwatcher_connamd} '#{@config_path}' #{@jvm_refind_interval} #{@log_interval} #{@log_buff_num} #{@setenv_path}"

  @io = IO.popen(command, "r")
  @pid = @io.pid
  @thread = Thread.new(&method(:run))
end