Method: Flydata::Command::Sender#flush_client_buffer

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

#flush_client_buffer(options = {}) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/flydata/command/sender.rb', line 65

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

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

  retry_count = 12
  1.upto(retry_count) do |i|
    return true if client_buffer_empty?
    log_info_stdout("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