lib/fluent/plugin/in_systemd.rb in fluent-plugin-systemd-1.0.3 vs lib/fluent/plugin/in_systemd.rb in fluent-plugin-systemd-1.0.4

- old
+ new

@@ -55,13 +55,19 @@ @mutator.warnings.each { |warning| log.warn(warning) } end def start super + @running = true timer_execute(:in_systemd_emit_worker, 1, &method(:run)) end + def shutdown + @running = false + super + end + private def init_journal # TODO: ruby 2.3 @journal.close if @journal # rubocop:disable Style/SafeNavigation @@ -129,10 +135,10 @@ def formatted(entry) @mutator.run(entry) end def watch(&block) - yield_current_entry(&block) while @journal.move_next + yield_current_entry(&block) while @running && @journal.move_next rescue Systemd::JournalError => e log.warn("Error moving to next Journal entry: #{e.class}: #{e.message}") end def yield_current_entry