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 <[email protected]>
  • Loading branch information
daipom committed May 31, 2022
1 parent 7b95dca commit 33fdfa8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/fluent/supervisor.rb
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
2 changes: 2 additions & 0 deletions test/config/test_system_config.rb
Original file line number Diff line number Diff line change
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 @@ -88,6 +89,7 @@ def parse_text(text)

data(
'workers' => ['workers', 3],
'restart_worker_interval' => ['restart_worker_interval', '1m'],
'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 33fdfa8

Please sign in to comment.