From 752c83fb59e799f261089aabd58ed3056960171d Mon Sep 17 00:00:00 2001 From: Yuta Iwama Date: Wed, 18 Dec 2019 16:21:32 +0900 Subject: [PATCH] Error raised in Thread is handled by myself Signed-off-by: Yuta Iwama --- lib/fluent/supervisor.rb | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/fluent/supervisor.rb b/lib/fluent/supervisor.rb index 488f0948cf..5a3f4dc1ec 100644 --- a/lib/fluent/supervisor.rb +++ b/lib/fluent/supervisor.rb @@ -192,30 +192,30 @@ def supervisor_sigusr1_handler def supervisor_sigusr2_handler conf = nil - Thread.new do + t = Thread.new do $log.info 'Reloading new config' - begin - # Validate that loading config is valid at first - conf = Fluent::Config.build( - config_path: config[:config_path], - encoding: config[:conf_encoding], - additional_config: config[:inline_config], - use_v1_config: config[:use_v1_config], - ) + # Validate that loading config is valid at first + conf = Fluent::Config.build( + config_path: config[:config_path], + encoding: config[:conf_encoding], + additional_config: config[:inline_config], + use_v1_config: config[:use_v1_config], + ) - Fluent::VariableStore.try_to_reset do - Fluent::Engine.reload_config(conf) - end - rescue => e - $log.error "Failed to reload config file: #{e}" - next + Fluent::VariableStore.try_to_reset do + Fluent::Engine.reload_config(conf, supervisor: true) end - end.join + end + + t.report_on_exception = false # Error is handled by myself + t.join reopen_log send_signal_to_workers(:USR2) @fluentd_conf = conf.to_s + rescue => e + $log.error "Failed to reload config file: #{e}" end def kill_worker @@ -776,7 +776,7 @@ def reload_config ) Fluent::VariableStore.try_to_reset do - Fluent::Engine.reload_config(conf, supervisor: true) + Fluent::Engine.reload_config(conf) end rescue => e # it is guranteed that config file is valid by supervisor side. but it's not atomic becuase of using signals to commnicate between worker and super