Skip to content

Commit

Permalink
Error raised in Thread is handled by myself
Browse files Browse the repository at this point in the history
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
  • Loading branch information
ganmacs committed Dec 18, 2019
1 parent 1bd4889 commit ae605ea
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions lib/fluent/supervisor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ae605ea

Please sign in to comment.