class Fluent::NamedPipeInput

Public Instance Methods

configure(conf) click to toggle source
Calls superclass method
# File lib/fluent/plugin/in_named_pipe.rb, line 21
def configure(conf)
  super

  begin
    pipe = PluginNamedPipe::Fifo.new(@path, :r)
    pipe.close # just to try open
  rescue => e
    raise ConfigError, "#{e.class}: #{e.message}"
  end

  @parser = Plugin.new_parser(@format)
  @parser.configure(conf)
end
run() click to toggle source
# File lib/fluent/plugin/in_named_pipe.rb, line 47
def run
  @pipe = PluginNamedPipe::Fifo.new(@path, :r)

  while @running
    begin
      line = @pipe.readline # blocking
      next if line.nil?
      
      @parser.parse(line) do |time, record|
        if time and record
          router.emit(@tag, time, record)
        else
          log.warn "Pattern not match: #{line.inspect}"
        end
      end
    rescue => e
      log.error "in_named_pipe: unexpected error", :error_class => e.class, :error => e.to_s
      log.error_backtrace
    end
  end
end
shutdown() click to toggle source
# File lib/fluent/plugin/in_named_pipe.rb, line 41
def shutdown
  @running = false
  @thread.join
  @pipe.close
end
start() click to toggle source
Calls superclass method
# File lib/fluent/plugin/in_named_pipe.rb, line 35
def start
  super
  @running = true
  @thread = Thread.new(&method(:run))
end