Skip to content

Commit df88590

Browse files
committed
Merge remote-tracking branch 'sf/fix-worker-lock'
2 parents c345cf5 + 26425d8 commit df88590

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/fluent/supervisor.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ def before_run
4444
@rpc_server = nil
4545
@counter = nil
4646

47+
@fluentd_lock_dir = Dir.mktmpdir("fluentd-lock-")
48+
ENV['FLUENTD_LOCK_DIR'] = @fluentd_lock_dir
49+
4750
if config[:rpc_endpoint]
4851
@rpc_endpoint = config[:rpc_endpoint]
4952
@enable_get_dump = config[:enable_get_dump]
@@ -73,9 +76,15 @@ def after_run
7376
stop_windows_event_thread if Fluent.windows?
7477
stop_rpc_server if @rpc_endpoint
7578
stop_counter_server if @counter
79+
cleanup_lock_dir
7680
Fluent::Supervisor.cleanup_resources
7781
end
7882

83+
def cleanup_lock_dir
84+
FileUtils.rm(Dir.glob(File.join(@fluentd_lock_dir, "fluentd-*.lock")))
85+
FileUtils.rmdir(@fluentd_lock_dir)
86+
end
87+
7988
def run_rpc_server
8089
@rpc_server = RPC::Server.new(@rpc_endpoint, $log)
8190

@@ -871,10 +880,7 @@ def supervise
871880
Fluent::Supervisor.load_config(@config_path, params)
872881
}
873882

874-
Dir.mktmpdir("fluentd-lock-") do |lock_dir|
875-
ENV['FLUENTD_LOCK_DIR'] = lock_dir
876-
se.run
877-
end
883+
se.run
878884
end
879885

880886
def install_main_process_signal_handlers

0 commit comments

Comments
 (0)