Skip to content

Commit

Permalink
Add new system-config to set interval to restart workers
Browse files Browse the repository at this point in the history
This fix needs the fix of ServerEngine:

* treasure-data/serverengine#120

Signed-off-by: Daijiro Fukuda <fukuda@clear-code.com>
  • Loading branch information
daipom committed Jun 10, 2022
1 parent 74ae3bb commit c2916a8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
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

0 comments on commit c2916a8

Please sign in to comment.