diff --git a/lib/fluent/supervisor.rb b/lib/fluent/supervisor.rb index cab076c50c..079eb4709b 100644 --- a/lib/fluent/supervisor.rb +++ b/lib/fluent/supervisor.rb @@ -50,9 +50,6 @@ def before_run @rpc_server = nil @counter = nil - @fluentd_lockdir = Dir.mktmpdir("fluentd-lock-") - ENV['FLUENTD_LOCKDIR'] = @fluentd_lockdir - if config[:rpc_endpoint] @rpc_endpoint = config[:rpc_endpoint] @enable_get_dump = config[:enable_get_dump] @@ -82,15 +79,9 @@ def after_run stop_windows_event_thread if Fluent.windows? stop_rpc_server if @rpc_endpoint stop_counter_server if @counter - cleanup_lockdir Fluent::Supervisor.cleanup_resources end - def cleanup_lockdir - FileUtils.rm(Dir.glob(File.join(@fluentd_lockdir, "fluentd-*.lock"))) - FileUtils.rmdir(@fluentd_lockdir) - end - def run_rpc_server @rpc_server = RPC::Server.new(@rpc_endpoint, $log) @@ -884,7 +875,11 @@ def supervise se = ServerEngine.create(ServerModule, WorkerModule){ Fluent::Supervisor.load_config(@config_path, params) } - se.run + + Dir.mktmpdir("fluentd-lock-") do |lockdir| + ENV['FLUENTD_LOCKDIR'] = lockdir + se.run + end end def install_main_process_signal_handlers