diff options
| -rw-r--r-- | lib/hcl/app.rb | 2 | ||||
| -rw-r--r-- | lib/hcl/commands.rb | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/hcl/app.rb b/lib/hcl/app.rb index 47a87af..5c98452 100644 --- a/lib/hcl/app.rb +++ b/lib/hcl/app.rb @@ -181,7 +181,7 @@ EOM def read_settings if File.exists? SETTINGS_FILE - @settings = YAML.load(File.read(SETTINGS_FILE)) + @settings = YAML.load(File.read(SETTINGS_FILE)) || {} else @settings = {} end diff --git a/lib/hcl/commands.rb b/lib/hcl/commands.rb index 4156a69..3e68c2b 100644 --- a/lib/hcl/commands.rb +++ b/lib/hcl/commands.rb @@ -10,6 +10,16 @@ module HCl http.config_hash.merge(password:'***').map {|k,v| "#{k}: #{v}" }.join("\n") end + # Show the network status of the Harvest service. + def status + result = Faraday.new("http://harveststatus.com/") do |f| + f.use :harvest, '', '' + f.adapter Faraday.default_adapter + end.get('status.json').body + date = Time.at(result[:last_check_time].to_i) + "Harvest is #{result[:status]}, response time: #{result[:last_response_time]}ms. [#{date}]" + end + def console Console.new(self) nil |
