Class: Fluent::GcInput
- Inherits:
-
Input
- Object
- Input
- Fluent::GcInput
- Defined in:
- lib/fluent/plugin/in_gc.rb
Instance Attribute Summary collapse
-
#last_checked ⇒ Object
Returns the value of attribute last_checked.
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #shutdown ⇒ Object
- #start ⇒ Object
- #start_gc ⇒ Object
-
#watcher ⇒ Object
thread callback.
Instance Attribute Details
#last_checked ⇒ Object
Returns the value of attribute last_checked.
8 9 10 |
# File 'lib/fluent/plugin/in_gc.rb', line 8 def last_checked @last_checked end |
Instance Method Details
#configure(conf) ⇒ Object
10 11 12 13 14 |
# File 'lib/fluent/plugin/in_gc.rb', line 10 def configure(conf) super @interval = @interval.to_i end |
#shutdown ⇒ Object
22 23 24 25 26 |
# File 'lib/fluent/plugin/in_gc.rb', line 22 def shutdown super @watcher.terminate @watcher.join end |
#start ⇒ Object
16 17 18 19 20 |
# File 'lib/fluent/plugin/in_gc.rb', line 16 def start super GC.disable if @disable @watcher = Thread.new(&method(:watcher)) end |
#start_gc ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/fluent/plugin/in_gc.rb', line 45 def start_gc $log.info "gc: before #{GC.stat}" if @debug # intentionally info level disabled = GC.enable GC.start GC.disable if disabled $log.info "gc: after #{GC.stat}" if @debug end |
#watcher ⇒ Object
thread callback
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fluent/plugin/in_gc.rb', line 29 def watcher @last_checked = Fluent::Engine.now while true sleep 0.5 begin if Fluent::Engine.now - @last_checked >= @interval now = Fluent::Engine.now start_gc @last_checked = now end rescue => e $log.warn "#{e.class} #{e.} #{e.backtrace.first}" end end end |