Skip to content

Commit

Permalink
Merge remote-tracking branch 'sf/fix-worker-lock'
Browse files Browse the repository at this point in the history
  • Loading branch information
fujimotos committed Aug 19, 2022
2 parents c345cf5 + 26425d8 commit df88590
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/fluent/supervisor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ def before_run
@rpc_server = nil
@counter = nil

@fluentd_lock_dir = Dir.mktmpdir("fluentd-lock-")
ENV['FLUENTD_LOCK_DIR'] = @fluentd_lock_dir

if config[:rpc_endpoint]
@rpc_endpoint = config[:rpc_endpoint]
@enable_get_dump = config[:enable_get_dump]
Expand Down Expand Up @@ -73,9 +76,15 @@ def after_run
stop_windows_event_thread if Fluent.windows?
stop_rpc_server if @rpc_endpoint
stop_counter_server if @counter
cleanup_lock_dir
Fluent::Supervisor.cleanup_resources
end

def cleanup_lock_dir
FileUtils.rm(Dir.glob(File.join(@fluentd_lock_dir, "fluentd-*.lock")))
FileUtils.rmdir(@fluentd_lock_dir)
end

def run_rpc_server
@rpc_server = RPC::Server.new(@rpc_endpoint, $log)

Expand Down Expand Up @@ -871,10 +880,7 @@ def supervise
Fluent::Supervisor.load_config(@config_path, params)
}

Dir.mktmpdir("fluentd-lock-") do |lock_dir|
ENV['FLUENTD_LOCK_DIR'] = lock_dir
se.run
end
se.run
end

def install_main_process_signal_handlers
Expand Down

0 comments on commit df88590

Please sign in to comment.