From e5a9dd1f1d19d7f95b6abbcef76483b14c2da0c1 Mon Sep 17 00:00:00 2001 From: Daijiro Fukuda Date: Fri, 10 Jun 2022 18:57:46 +0900 Subject: [PATCH] Add new system-config to set interval to restart workers This fix needs the fix of ServerEngine: * https://github.com/treasure-data/serverengine/pull/120 Signed-off-by: Daijiro Fukuda --- lib/fluent/supervisor.rb | 6 ++++-- lib/fluent/system_config.rb | 3 ++- test/config/test_system_config.rb | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/fluent/supervisor.rb b/lib/fluent/supervisor.rb index 5ac5ce4bf2..0bd82ece47 100644 --- a/lib/fluent/supervisor.rb +++ b/lib/fluent/supervisor.rb @@ -493,7 +493,8 @@ def self.load_config(path, params = {}) config_path: path, main_cmd: params['main_cmd'], signame: params['signame'], - disable_shared_socket: params['disable_shared_socket'] + disable_shared_socket: params['disable_shared_socket'], + restart_worker_interval: params['restart_worker_interval'], } if daemonize se_config[:pid_path] = pid_path @@ -867,7 +868,8 @@ def supervise 'counter_server' => @system_config.counter_server, 'log_format' => @system_config.log.format, 'log_time_format' => @system_config.log.time_format, - 'disable_shared_socket' => @system_config.disable_shared_socket + 'disable_shared_socket' => @system_config.disable_shared_socket, + 'restart_worker_interval' => @system_config.restart_worker_interval, } se = ServerEngine.create(ServerModule, WorkerModule){ diff --git a/lib/fluent/system_config.rb b/lib/fluent/system_config.rb index bbb1040d67..df2f2387a7 100644 --- a/lib/fluent/system_config.rb +++ b/lib/fluent/system_config.rb @@ -22,7 +22,7 @@ class SystemConfig include Configurable SYSTEM_CONFIG_PARAMETERS = [ - :workers, :root_dir, :log_level, + :workers, :restart_worker_interval, :root_dir, :log_level, :suppress_repeated_stacktrace, :emit_error_log_interval, :suppress_config_dump, :log_event_verbose, :ignore_repeated_log_interval, :ignore_same_log_interval, :without_source, :rpc_endpoint, :enable_get_dump, :process_name, @@ -32,6 +32,7 @@ class SystemConfig ] config_param :workers, :integer, default: 1 + config_param :restart_worker_interval, :time, default: 0 config_param :root_dir, :string, default: nil config_param :log_level, :enum, list: [:trace, :debug, :info, :warn, :error, :fatal], default: 'info' config_param :suppress_repeated_stacktrace, :bool, default: nil diff --git a/test/config/test_system_config.rb b/test/config/test_system_config.rb index f4240ab30e..d347bbe828 100644 --- a/test/config/test_system_config.rb +++ b/test/config/test_system_config.rb @@ -19,6 +19,7 @@ def initialize(**opt) @system_config = nil @cl_opt = { wokers: nil, + restart_worker_interval: nil, root_dir: nil, log: FakeLoggerInitializer.new, log_level: Fluent::Log::LEVEL_INFO, @@ -72,6 +73,7 @@ def parse_text(text) sc = Fluent::SystemConfig.new(conf) sc.overwrite_variables(**s.for_system_config) assert_equal(1, sc.workers) + assert_equal(0, sc.restart_worker_interval) assert_nil(sc.root_dir) assert_equal(Fluent::Log::LEVEL_INFO, sc.log_level) assert_nil(sc.suppress_repeated_stacktrace) @@ -88,6 +90,7 @@ def parse_text(text) data( 'workers' => ['workers', 3], + 'restart_worker_interval' => ['restart_worker_interval', 60], 'root_dir' => ['root_dir', File.join(TMP_DIR, 'root')], 'log_level' => ['log_level', 'error'], 'suppress_repeated_stacktrace' => ['suppress_repeated_stacktrace', true],