Class: Fluent::ConfigReloaderOutput::ReloadFileWatcher
- Inherits:
-
Object
- Object
- Fluent::ConfigReloaderOutput::ReloadFileWatcher
- Includes:
- Observable
- Defined in:
- lib/fluent/plugin/out_config_reloader.rb
Instance Attribute Summary collapse
-
#thread ⇒ Object
readonly
Returns the value of attribute thread.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#thread ⇒ Object (readonly)
Returns the value of attribute thread.
13 14 15 |
# File 'lib/fluent/plugin/out_config_reloader.rb', line 13 def thread @thread end |
Class Method Details
.create(observer, watch_file, interval) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/fluent/plugin/out_config_reloader.rb', line 15 def self.create(observer, watch_file, interval) obj = self.new obj.add_observer(observer) obj.watch watch_file, interval obj end |
Instance Method Details
#watch(watch_file, interval) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fluent/plugin/out_config_reloader.rb', line 23 def watch watch_file, interval mtime = Time.now @thread = Thread.new do loop do if File.exists?(watch_file) && File.mtime(watch_file) > mtime mtime = File.mtime(watch_file) changed notify_observers end sleep interval end end end |