Method: Flydata::Command::Sender#flush_client_buffer

Defined in:
lib/flydata/command/sender.rb

#flush_client_buffer(options = {}) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/flydata/command/sender.rb', line 54

def flush_client_buffer(options = {})
  unless process_exist?
    return true if client_buffer_empty?
    say("Process doesn't exist. But, the client buffer is not empty!!") unless options[:quiet]
    start(options)
  end

  say('Stopping input plugins and flushing the client buffer.') unless options[:quiet]
  Kernel.system("kill -USR1 `cat #{FLYDATA_HOME}/flydata.pid`")

  retry_count = 12
  1.upto(retry_count) do |i|
    return true if client_buffer_empty?
    say("Waiting for the buffer to get empty... (#{i}/#{retry_count})") unless options[:quiet]
    Kernel.sleep 5
  end

  raise 'Something is wrong! Unable to flush client buffer'
end