Skip to content

Commit cdbdf39

Browse files
committed
feat(in_exec): add command_timeout option to limit child process execution time
1 parent c603d04 commit cdbdf39

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/fluent/plugin/in_exec.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ class ExecInput < Fluent::Plugin::Input
4343
config_param :tag, :string, default: nil
4444
desc 'The interval time between periodic program runs.'
4545
config_param :run_interval, :time, default: nil
46+
desc 'Command (program) execution timeout.'
47+
config_param :command_timeout, :time, default: nil
4648
desc 'The default block size to read if parser requires partial read.'
4749
config_param :read_block_size, :size, default: 10240 # 10k
4850
desc 'The encoding to receive the result of the command, especially for non-ascii characters.'
@@ -86,9 +88,9 @@ def start
8688
options[:external_encoding] = @encoding if @encoding
8789

8890
if @run_interval
89-
child_process_execute(:exec_input, @command, interval: @run_interval, **options, &method(:run))
91+
child_process_execute(:exec_input, @command, interval: @run_interval, wait_timeout: @command_timeout, **options, &method(:run))
9092
else
91-
child_process_execute(:exec_input, @command, immediate: true, **options, &method(:run))
93+
child_process_execute(:exec_input, @command, immediate: true, wait_timeout: @command_timeout, **options, &method(:run))
9294
end
9395
end
9496

0 commit comments

Comments
 (0)