Class: Scout::Command::Install

Inherits:
Scout::Command show all
Defined in:
lib/es-scout/command/install.rb

Constant Summary

Constants inherited from Scout::Command

HTTP_HEADERS

Instance Attribute Summary

Attributes inherited from Scout::Command

#config_dir, #history, #log_path, #server

Instance Method Summary collapse

Methods inherited from Scout::Command

#create_pid_file_or_exit, dispatch, #initialize, #level, #log, program_name, #program_name, program_path, #program_path, usage, #usage, user, #user, #verbose?

Constructor Details

This class inherits a constructor from Scout::Command

Instance Method Details

#runObject



6
7
8
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/es-scout/command/install.rb', line 6

def run
  create_pid_file_or_exit

  abort usage unless $stdin.tty?
  
  puts <<-END_INTRO.gsub(/^ {8}/, "")
  === Scout Installation Wizard ===

  You need the Server Key displayed in the Server Settings tab.
  It looks like:

    6ecad322-0d17-4cb8-9b2c-a12c4541853f

  Enter the Server Key:
  END_INTRO
  key = gets.to_s.strip

  puts "\nAttempting to contact the server..."
  begin
    Scout::Server.new(server, key, history, log) do |scout|
      scout.fetch_plan
      scout.run_plugins_by_plan
    end

    puts <<-END_SUCCESS.gsub(/^ {10}/, "")
    Success!

    Now, you must setup Scout to run on a scheduled basis.

    If you are using the system crontab
    (usually located at /etc/crontab):

    ****** START CRONTAB SAMPLE ******
    * * * * *  #{user} #{program_path} #{key}
    ******  END CRONTAB SAMPLE  ******

    If you are using this current user's crontab
    (using crontab -e to edit):

    ****** START CRONTAB SAMPLE ******
    * * * * *  #{program_path} #{key}
    ******  END CRONTAB SAMPLE  ******

    For help setting up Scout with crontab, please visit:

      http://scoutapp.com/help#cron

    END_SUCCESS
  rescue SystemExit
    puts $!.message
    puts <<-END_ERROR.gsub(/^ {10}/, "")

    Failed. 
    For more help, please visit:

    http://scoutapp.com/help

    END_ERROR
  end
end