Class: Flydata::Command::Setup

Inherits:
Base
  • Object
show all
Includes:
Helpers
Defined in:
lib/flydata/command/setup.rb

Constant Summary collapse

LOG_PATH_EXAMPLES =
%w(/var/log/httpd/access_log /var/log/apache2/access.log
/var/log/httpd-access.log /var/log/apache2/access_log
/var/log/messages /var/log/maillog /var/log/mysql/error.log
/home/*/deploy/shared/log/*.log)
OTHER =
'-- None of above --'
ENTER_TABLE_NAME =
'-- Create a table on Redshift from your logs --'

Instance Method Summary collapse

Methods included from Helpers

development?, env_mode, env_suffix, flydata_api_host_file, flydata_conf_file, format_menu_list, parse_command, print_usage, to_command_class

Methods inherited from Base

#ask_input_table_name, #ask_yes_no, #choose_one, #flydata, #initialize, #newline, #register_crontab, #retrieve_data_entries, #separator

Constructor Details

This class inherits a constructor from Flydata::Command::Base

Instance Method Details

#initial_runObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/flydata/command/setup.rb', line 22

def initial_run
  last_message = nil
  run do
    Flydata::Command::Conf.new.copy_templates
    puts
    shown_redshift_entries = (show_registered_redshift_entries)
    shown_mysql_data_entries = show_registered_redshift_mysql_data_entries
    if shown_redshift_entries
      Flydata::Command::Sender.new.stop
      true
    elsif shown_mysql_data_entries
      de = retrieve_data_entries.first
      if File.exists?(Flydata::FileUtil::SyncFileManager.new(de).binlog_path)
        Flydata::Command::Sender.new.stop
        true
      else
        last_message =  "\n! NOTE: Initial synchronization of MySQL database is required.\n" +
                        "  Please run 'flydata sync' to start synchronization."
        false
      end
    else
      _run
    end
  end
  puts
  print_usage
  puts "Completed setup of FlyData!"
  puts last_message if last_message
end

#run(&block) ⇒ Object



52
53
54
55
56
# File 'lib/flydata/command/setup.rb', line 52

def run(&block)
  Flydata::Command::Login.new.run unless flydata.credentials.authenticated?
  ret = block_given? ? yield : _run
  Flydata::Command::Sender.new.restart if ret
end