@@ -80,6 +80,8 @@ def initialize
80
80
config_param :emit_unmatched_lines , :bool , default : false
81
81
desc 'Enable the additional watch timer.'
82
82
config_param :enable_watch_timer , :bool , default : true
83
+ desc 'Enable the stat watcher based on inotify.'
84
+ config_param :enable_stat_watcher , :bool , default : true
83
85
desc 'The encoding after conversion of the input.'
84
86
config_param :encoding , :string , default : nil
85
87
desc 'The encoding of the input.'
@@ -115,6 +117,10 @@ def configure(conf)
115
117
116
118
super
117
119
120
+ if !@enable_watch_timer && !@enable_stat_watcher
121
+ raise Fluent ::ConfigError , "either of enable_watch_timer or enable_stat_watcher must be true"
122
+ end
123
+
118
124
@paths = @path . split ( ',' ) . map { |path | path . strip }
119
125
if @paths . empty?
120
126
raise Fluent ::ConfigError , "tail: 'path' parameter is required on tail input"
@@ -254,10 +260,10 @@ def refresh_watchers
254
260
255
261
def setup_watcher ( path , pe )
256
262
line_buffer_timer_flusher = ( @multiline_mode && @multiline_flush_interval ) ? TailWatcher ::LineBufferTimerFlusher . new ( log , @multiline_flush_interval , &method ( :flush_buffer ) ) : nil
257
- tw = TailWatcher . new ( path , @rotate_wait , pe , log , @read_from_head , @enable_watch_timer , @read_lines_limit , method ( :update_watcher ) , line_buffer_timer_flusher , @from_encoding , @encoding , open_on_every_update , &method ( :receive_lines ) )
263
+ tw = TailWatcher . new ( path , @rotate_wait , pe , log , @read_from_head , @enable_watch_timer , @enable_stat_watcher , @ read_lines_limit, method ( :update_watcher ) , line_buffer_timer_flusher , @from_encoding , @encoding , open_on_every_update , &method ( :receive_lines ) )
258
264
tw . attach do |watcher |
259
265
watcher . timer_trigger = timer_execute ( :in_tail_timer_trigger , 1 , &watcher . method ( :on_notify ) ) if watcher . enable_watch_timer
260
- event_loop_attach ( watcher . stat_trigger )
266
+ event_loop_attach ( watcher . stat_trigger ) if watcher . enable_stat_watcher
261
267
end
262
268
tw
263
269
rescue => e
@@ -457,17 +463,18 @@ def parse_multilines(lines, tail_watcher)
457
463
end
458
464
459
465
class TailWatcher
460
- def initialize ( path , rotate_wait , pe , log , read_from_head , enable_watch_timer , read_lines_limit , update_watcher , line_buffer_timer_flusher , from_encoding , encoding , open_on_every_update , &receive_lines )
466
+ def initialize ( path , rotate_wait , pe , log , read_from_head , enable_watch_timer , enable_stat_watcher , read_lines_limit , update_watcher , line_buffer_timer_flusher , from_encoding , encoding , open_on_every_update , &receive_lines )
461
467
@path = path
462
468
@rotate_wait = rotate_wait
463
469
@pe = pe || MemoryPositionEntry . new
464
470
@read_from_head = read_from_head
465
471
@enable_watch_timer = enable_watch_timer
472
+ @enable_stat_watcher = enable_stat_watcher
466
473
@read_lines_limit = read_lines_limit
467
474
@receive_lines = receive_lines
468
475
@update_watcher = update_watcher
469
476
470
- @stat_trigger = StatWatcher . new ( self , &method ( :on_notify ) )
477
+ @stat_trigger = @enable_stat_watcher ? StatWatcher . new ( self , &method ( :on_notify ) ) : nil
471
478
@timer_trigger = nil
472
479
473
480
@rotate_handler = RotateHandler . new ( self , &method ( :on_rotate ) )
@@ -483,7 +490,7 @@ def initialize(path, rotate_wait, pe, log, read_from_head, enable_watch_timer, r
483
490
attr_reader :path
484
491
attr_reader :log , :pe , :read_lines_limit , :open_on_every_update
485
492
attr_reader :from_encoding , :encoding
486
- attr_reader :stat_trigger , :enable_watch_timer
493
+ attr_reader :stat_trigger , :enable_watch_timer , :enable_stat_watcher
487
494
attr_accessor :timer_trigger
488
495
attr_accessor :line_buffer , :line_buffer_timer_flusher
489
496
attr_accessor :unwatched # This is used for removing position entry from PositionFile
@@ -503,7 +510,7 @@ def attach
503
510
504
511
def detach
505
512
@timer_trigger . detach if @enable_watch_timer && @timer_trigger && @timer_trigger . attached?
506
- @stat_trigger . detach if @stat_trigger && @stat_trigger . attached?
513
+ @stat_trigger . detach if @enable_stat_watcher && @ stat_trigger && @stat_trigger . attached?
507
514
@io_handler . on_notify if @io_handler
508
515
end
509
516
0 commit comments