Method: Flydata::Command::Sender#start

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

#start(options_or_show_final_message = {show_final_message: true}) ⇒ Object

For backward compatibility. Use only as options going forward



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/flydata/command/sender.rb', line 9

def start(options_or_show_final_message = {show_final_message: true}) # For backward compatibility. Use only as options going forward 
  if options_or_show_final_message.kind_of? Hash
    options = options_or_show_final_message
  else
    options = {show_final_message: options_or_show_final_message}
  end
  # Check if process exist
  if process_exist?
    say("Process is still running. Please stop process first.") unless options[:quiet]
    return
  end

  wait_until_server_ready(options)

  # Start sender(fluentd) process
  say('Starting sender process.') unless options[:quiet]
  Dir.chdir(FLYDATA_HOME){
    daemon_option = opts.no_daemon? ? "" : "-d #{FLYDATA_HOME}/flydata.pid"
    Kernel.system("fluentd #{daemon_option} -l #{FLYDATA_HOME}/flydata.log -c #{FLYDATA_HOME}/flydata.conf -p #{File.dirname(__FILE__)}/../fluent-plugins")
  }
  Kernel.sleep 5

  wait_until_client_ready(options)
  #wait_until_logs_uploaded
  if options[:show_final_message] && !options[:quiet]
    data_port = flydata.data_port.get
    say("Go to your Dashboard! #{flydata.flydata_api_host}/data_ports/#{data_port['id']}")
    say "Please Note: Records and Total Size are updated every 10-20 minutes.\n"
  end
end