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.



26
27
28
29
30
31
32
# File 'lib/fluent/plugin/in_jvmwatcher.rb', line 26

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



58
59
60
# File 'lib/fluent/plugin/in_jvmwatcher.rb', line 58

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

#shutdownObject



49
50
51
52
53
54
55
56
# File 'lib/fluent/plugin/in_jvmwatcher.rb', line 49

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

#startObject



40
41
42
43
44
45
46
47
# File 'lib/fluent/plugin/in_jvmwatcher.rb', line 40

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