diff --git a/lib/fluent/compat/call_super_mixin.rb b/lib/fluent/compat/call_super_mixin.rb index c8099a82d1..24be38e112 100644 --- a/lib/fluent/compat/call_super_mixin.rb +++ b/lib/fluent/compat/call_super_mixin.rb @@ -55,6 +55,15 @@ def before_shutdown end end + def stop + klass = self.class + @@_super_start.delete(klass) + @@_super_before_shutdown.delete(klass) + @@_super_shutdown.delete(klass) + + super + end + def shutdown super unless self.shutdown? diff --git a/lib/fluent/plugin/buf_file.rb b/lib/fluent/plugin/buf_file.rb index c56425f018..d64e294c68 100644 --- a/lib/fluent/plugin/buf_file.rb +++ b/lib/fluent/plugin/buf_file.rb @@ -50,6 +50,7 @@ def initialize @symlink_path = nil @multi_workers_available = false @additional_resume_path = nil + @buffer_path = nil end def configure(conf) @@ -73,7 +74,8 @@ def configure(conf) raise ConfigError, "Other '#{type_using_this_path}' plugin already use same buffer path: type = #{type_of_owner}, buffer path = #{@path}" end - @@buffer_paths[@path] = type_of_owner + @buffer_path = @path + @@buffer_paths[@buffer_path] = type_of_owner specified_directory_exists = File.exist?(@path) && File.directory?(@path) unexisting_path_for_directory = !File.exist?(@path) && !@path.include?('.*') @@ -122,6 +124,12 @@ def start super end + def stop + @@buffer_paths.delete(@buffer_path) + + super + end + def persistent? true end diff --git a/lib/fluent/plugin/buf_file_single.rb b/lib/fluent/plugin/buf_file_single.rb index a4f4455f12..738654001e 100644 --- a/lib/fluent/plugin/buf_file_single.rb +++ b/lib/fluent/plugin/buf_file_single.rb @@ -144,6 +144,12 @@ def start super end + def stop + @@buffer_paths.delete(@path) + + super + end + def persistent? true end diff --git a/lib/fluent/plugin/in_tail.rb b/lib/fluent/plugin/in_tail.rb index a2f6b5c471..6a226a544d 100644 --- a/lib/fluent/plugin/in_tail.rb +++ b/lib/fluent/plugin/in_tail.rb @@ -204,6 +204,12 @@ def start timer_execute(:in_tail_refresh_watchers, @refresh_interval, &method(:refresh_watchers)) end + def stop + @@pos_file_paths.delete(@pos_file) + + super + end + def shutdown # during shutdown phase, don't close io. It should be done in close after all threads are stopped. See close. stop_watchers(@tails.keys, immediate: true, remove_watcher: false) diff --git a/lib/fluent/plugin_id.rb b/lib/fluent/plugin_id.rb index d43f7b145d..e704db9bf4 100644 --- a/lib/fluent/plugin_id.rb +++ b/lib/fluent/plugin_id.rb @@ -76,5 +76,11 @@ def plugin_root_dir @_plugin_root_dir = dir.freeze dir end + + def stop + @@configured_ids.delete(@id) + + super + end end end