Skip to content

Commit

Permalink
Merge pull request #1487 from t-osakada/skip_refresh_on_startup
Browse files Browse the repository at this point in the history
Skip the refresh of watching list on startup.
  • Loading branch information
repeatedly committed Mar 9, 2017
1 parent 2c83da3 commit 3c80765
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/fluent/plugin/in_tail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ def initialize
config_param :path_key, :string, default: nil
desc 'Limit the watching files that the modification time is within the specified time range (when use \'*\' in path).'
config_param :limit_recently_modified, :time, default: nil
desc 'Enable the option to skip the refresh of watching list on startup.'
config_param :skip_refresh_on_startup, :bool, default: false

attr_reader :paths

Expand Down Expand Up @@ -130,7 +132,7 @@ def start
end

@loop = Coolio::Loop.new
refresh_watchers
refresh_watchers unless @skip_refresh_on_startup

@refresh_trigger = TailWatcher::TimerWatcher.new(@refresh_interval, true, log, &method(:refresh_watchers))
@refresh_trigger.attach(@loop)
Expand Down
15 changes: 15 additions & 0 deletions test/plugin/test_in_tail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1036,4 +1036,19 @@ def test_limit_recently_modified
assert_equal expected_files, plugin.expand_paths.sort
end
end

def test_skip_refresh_on_startup
FileUtils.touch("#{TMP_DIR}/tail.txt")
config = config_element('', '', {
'tag' => 'tail',
'path' => "#{TMP_DIR}/*.txt",
'format' => 'none',
'refresh_interval' => 1,
'skip_refresh_on_startup' => true
})
d = create_driver(config, false)
d.run {
sleep 0.1 until d.instance.instance_variable_get(:@tails).keys.size == 1
}
end
end

0 comments on commit 3c80765

Please sign in to comment.