Class: Skylight::CLI::Doctor
Instance Attribute Summary
Attributes included from Thor::Base
#args, #options, #parent_options
Instance Method Summary
collapse
Methods inherited from Thor::Group
class_options_help, desc, get_options_from_invocations, handle_argument_error, help, invocation_blocks, invocations, invoke, invoke_from_option, printable_commands, remove_invocation
Methods included from Thor::Base
included, #initialize, register_klass_file, shell, shell=, subclass_files, subclasses
Instance Method Details
#check_config ⇒ Object
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/skylight/cli/doctor.rb', line 83
def check_config
say "Checking for valid configuration"
indent do
config.validate!
say "Configuration is valid", :green
rescue ConfigError => e
encountered_error!
say "Configuration is invalid", :red
indent do
say e.message, :red
say "This may occur if you are configuring with ENV variables and didn't set them in this shell."
end
done!
end
puts "\n"
end
|
#check_daemon ⇒ Object
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
# File 'lib/skylight/cli/doctor.rb', line 104
def check_daemon
say "Checking Skylight startup"
indent do
logger = Logger.new("/dev/null")
logger.level = Logger::DEBUG
logger.formatter =
proc do |severity, _datetime, _progname, msg|
msg = msg.sub("[SKYLIGHT] [#{Skylight::VERSION}] ", "")
say "#{severity} - #{msg}" end
config.logger = logger
config.set(:"daemon.lazy_start", false)
started = Skylight.start!(config)
if started
say "Successfully started", :green
else
encountered_error!
say "Failed to start", :red
done!
end
say "Waiting for daemon... "
tries = 0
daemon_running = false
while tries < 5
`ps cax | grep skylightd`
if $CHILD_STATUS.success?
daemon_running = true
break
end
tries += 1
sleep 1
end
if daemon_running
say "Success", :green
else
encountered_error!
say "Failed", :red
end
end
say "\n"
end
|
#check_native ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/skylight/cli/doctor.rb', line 56
def check_native
say "Checking for native agent"
indent do
if Skylight.native?
say "Native agent installed", :green
else
encountered_error!
say "Unable to load native extension", :yellow
indent do
install_log = File.expand_path("../../../ext/install.log", __dir__)
if File.exist?(install_log)
File.readlines(install_log).each { |line| say line, :red }
else
say "Reason unknown", :red
end
end
done!
end
end
say "\n"
end
|
#check_rails ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/skylight/cli/doctor.rb', line 40
def check_rails
say "Checking for Rails"
indent do
if rails?
say "Rails application detected", :green
else
say "No Rails application detected", :yellow
say "Additional `skylight doctor` checks only work with Rails applications.", :yellow
done!
end
end
say "\n"
end
|
#check_ssl ⇒ Object
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
|
# File 'lib/skylight/cli/doctor.rb', line 10
def check_ssl
say "Checking SSL"
http = Util::HTTP.new(config)
indent do
req = http.get("/status")
if req.success?
say "OK", :green
else
encountered_error!
if req.exception.is_a?(Util::HTTP::StartError) && req.exception.original.is_a?(OpenSSL::SSL::SSLError)
say "Failed to verify SSL certificate.", :red
if Util::SSL.ca_cert_file?
say "Certificates located at #{Util::SSL.ca_cert_file_or_default} may be out of date.", :yellow
if mac? && rvm_present?
say "Please update your certificates with RVM by running `rvm osx-ssl-certs update all`.", :yellow
say "Alternatively, try setting `SKYLIGHT_FORCE_OWN_CERTS=1` in your environment.", :yellow
else
say "Please update your local certificates or try setting `SKYLIGHT_FORCE_OWN_CERTS=1` in your " \
"environment.",
:yellow
end
end
else
say "Unable to reach Skylight servers.", :red
end
end
end
say "\n"
end
|
164
165
166
|
# File 'lib/skylight/cli/doctor.rb', line 164
def wrap_up
done!
end
|