Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new system-config to set interval to restart workers #3768

Merged
merged 1 commit into from Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/fluent/supervisor.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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){
Expand Down
3 changes: 2 additions & 1 deletion lib/fluent/system_config.rb
Expand Up @@ -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,
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions test/config/test_system_config.rb
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand All @@ -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],
Expand Down