Sha256: c78a9f7fe2844f2b955cf69a285abdf26c515475a8be000fe3aa1dfb261259ff
Contents?: true
Size: 1.89 KB
Versions: 5
Compression:
Stored size: 1.89 KB
Contents
module Freyr class CLI < Thor desc 'list', 'lists all available services:' method_option :ping, :type => :boolean, :default => false, :aliases => '-p', :desc => 'also ping each service which can ping' method_option :info, :type => :boolean, :default => false, :aliases => '-i', :desc => 'also get cpu and memory info' def list strs = list_all_services(:ping => options.ping?, :procinfo => options.info?) if strs.empty? say "No services available", :red else say "List of all available services (#{set_color('*', :yellow)} denotes root proc)" strs.each_with_index do |s,i| say s end end end desc 'tail [SERVICE=dirname]', 'read stdout of the service' method_option :lines, :type => :numeric, :default => 50, :desc => 'Number of lines to show on initial tail' method_option :'no-follow', :type => :boolean, :default => false, :desc => 'Disable auto follow, just print tail and exit' def tail(name=nil) services = get_from_name(name) if !services.empty? services.first.tail!(options.lines, !options['no-follow']) else say "Can't find the #{name} service", :red end end desc 'ping', 'see the response from pinging the url' def ping(name=nil) service = get_from_name(name).first if service if service.ping pinger = Pinger.new(service) resp = pinger.ping if pinger.success? say "Up and running", :green elsif pinger.server_error? say "500 Error" elsif resp say "Returned #{resp.code} code", :red else say "Couldn't reach service", :red end else say 'No url to ping for this service' end else say "Can't find the #{name} service", :red end end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
freyr-0.3.7 | lib/freyr/cli/monitor.rb |
freyr-0.3.6 | lib/freyr/cli/monitor.rb |
freyr-0.3.5 | lib/freyr/cli/monitor.rb |
freyr-0.3.4 | lib/freyr/cli/monitor.rb |
freyr-0.3.3 | lib/freyr/cli/monitor.rb |