Method: Fluent::SendmailInput#configure

Defined in:
lib/fluent/plugin/in_sendmail.rb

#configure(conf) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fluent/plugin/in_sendmail.rb', line 14

def configure(conf)
  super
  @delivers = LruRedux::ThreadSafeCache.new(@lrucache_size)
  if @path_cache_file != nil
    if not File.exists?(@path_cache_file)
      File.open(@path_cache_file, "w+"){|cache_file|
        cache_file.puts('{}')
      }
    end
    if not File.readable?(@path_cache_file)
      raise ConfigError, "cache file exists but not readable."
    end
    if not File.writable?(@path_cache_file)
      raise Fluent::ConfigError, "cache file not writable."
    end
    File.open(@path_cache_file, "r") {|cache_file|
      line = cache_file.read()
      data = JSON.parse(line)
      data.each{|k, v|
        @delivers[k] = SendmailLog.new(v['time'], v['from_line'], v['nrcpts'])
      }
    }
  end
end