Class: Flydata::Command::Setup

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

Constant Summary collapse

ALL_DONE_MESSAGE_TEMPLATE =
<<-EOM
Congratulations! FlyData has started uploading your data.

To complete your installation and to add the `flydata` command, please run the
following from the command line.

    $ source ~/.bashrc


What's next?

    - Check data on Redshift (%s)
    - Check your FlyData usage on the FlyData Dashboard (%s)
    - To manage the FlyData Agent, use the 'flydata' command (type 'flydata' for
help)
    - If you encounter an issue,
  please check our documentation (https://www.flydata.com/resources/) or
  contact our customer support team ([email protected])

Thank you for using FlyData!
EOM
INITIAL_SYNC_MESSAGE_TEMPLATE =
<<-EOM
FlyData Agent has been installed on your server successfully.

To complete your installation and to add the `flydata` command, please run the
following from the command line.

    $ source ~/.bashrc


What's next?

1. Generate a script to create tables on Redshift by running the following command.

    $ flydata sync:generate_table_ddl > create_table.sql

2. Create tables on Redshift by running the 'create_table.sql' script on your Redshift cluster.
    The script is auto-generated from your MySQL tables.  You can also edit the script to add extra Redshift parameters such as distkey and sortkey.  Once you run the script and create tables in Redshift, you are ready for the next step.

3. Start Sync
    Run the following command on your server. The command will start synchronizing data between MySQL and Redshift!

    $ flydata start

EOM
NO_DE_CANCEL_MESSAGE_TEMPLATE =
<<-EOM
FlyData Agent has been installed on your server successfully.
However, you need to create at least a data entry before you can start using FlyData.

What's next?

1. Create a data entry from the dashboard (%s)

2. Reinstall FlyData Agent by running the install command on the dashboard

EOM

Instance Attribute Summary

Attributes inherited from Base

#opts

Instance Method Summary collapse

Methods inherited from Base

#ask_input_table_name, #ask_yes_no, #choose_one, #dashboard_url, #data_entry, #data_port, #flydata, #initialize, #newline, #redshift_cluster, #redshift_console_url, #register_crontab, #retrieve_data_entries, #separator, #show_purpose_name, #source

Methods included from ExclusiveRunnable

included

Methods included from Flydata::CommandLoggable

#before_logging, #log_error_stderr, #log_info_stdout, #log_warn_stderr

Constructor Details

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

Instance Method Details

#initial_runObject


70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/flydata/command/setup.rb', line 70

def initial_run
  # Surprisingly, Helper's start method kills the process after starting
  # the helper thanks to ServerEngine.  So the command needs to run in a
  # separate process.
  system "flydata helper:restart"
  Flydata::Command::Login.new.run unless flydata.credentials.authenticated?
  Flydata::Command::Conf.new.copy_templates
  puts
  de_exists = !!retrieve_data_entries.first
  if de_exists && source.setup.initial_run_need_restart?
    sender = Flydata::Command::Sender.new
    if sender.process_exist?
      Flydata::Command::Sender.new.restart(quiet: true)
    end
  end
  last_message = de_exists ? source.setup.initial_run_complete_message
                            : :no_de_cancel
  msgs = standard_messages
  if msgs.has_key?(last_message)
    last_message = msgs[last_message]
  end
  puts last_message
end

#run(options = {}, &block) ⇒ Object


94
95
96
97
98
99
100
# File 'lib/flydata/command/setup.rb', line 94

def run(options = {}, &block)
  unless data_entry
    raise "No data entry exists.  Please create one from FlyData Console (#{dashboard_url})"
  end
  # 'flydata setup' command is deprecated
  raise "You can set up FlyData on FlyData Console (#{dashboard_url})"
end