Skip to content

Commit

Permalink
storage_local: Don't stop fluentd start when existing file is empty. …
Browse files Browse the repository at this point in the history
…ref #2373

Signed-off-by: Masahiro Nakagawa <repeatedly@gmail.com>
  • Loading branch information
repeatedly committed May 10, 2019
1 parent 1374b4b commit ba7c201
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/fluent/plugin/storage_local.rb
Expand Up @@ -87,7 +87,12 @@ def configure(conf)
if File.exist?(@path)
raise Fluent::ConfigError, "Plugin storage path '#{@path}' is not readable/writable" unless File.readable?(@path) && File.writable?(@path)
begin
data = Yajl::Parser.parse(open(@path, 'r:utf-8'){ |io| io.read })
data = open(@path, 'r:utf-8') { |io| io.read }
if data.empty?
log.warn "detect empty plugin storage file during startup. Ignored: #{@path}"
return
end
data = Yajl::Parser.parse(data)
raise Fluent::ConfigError, "Invalid contents (not object) in plugin storage file: '#{@path}'" unless data.is_a?(Hash)
rescue => e
log.error "failed to read data from plugin storage file", path: @path, error: e
Expand Down

0 comments on commit ba7c201

Please sign in to comment.