Class: Procodile::StatusCLIOutput
- Inherits:
-
Object
- Object
- Procodile::StatusCLIOutput
- Defined in:
- lib/procodile/status_cli_output.rb
Instance Method Summary collapse
-
#initialize(status) ⇒ StatusCLIOutput
constructor
A new instance of StatusCLIOutput.
- #print_all ⇒ Object
- #print_header ⇒ Object
- #print_processes ⇒ Object
Constructor Details
#initialize(status) ⇒ StatusCLIOutput
Returns a new instance of StatusCLIOutput.
6 7 8 |
# File 'lib/procodile/status_cli_output.rb', line 6 def initialize(status) @status = status end |
Instance Method Details
#print_all ⇒ Object
10 11 12 13 |
# File 'lib/procodile/status_cli_output.rb', line 10 def print_all print_header print_processes end |
#print_header ⇒ Object
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 |
# File 'lib/procodile/status_cli_output.rb', line 15 def print_header puts "Procodile Version " + @status['version'].to_s.color(34) puts "Application Root " + "#{@status['root']}".color(34) puts "Supervisor PID " + "#{@status['supervisor']['pid']}".color(34) if time = @status['supervisor']['started_at'] time = Time.at(time) puts "Started " + "#{time.to_s}".color(34) end if @status['environment_variables'] && !@status['environment_variables'].empty? @status['environment_variables'].each_with_index do |(key, value), index| if index == 0 print "Environment Vars " else print " " end print key.color(34) puts " " + value.to_s end end unless @status['messages'].empty? puts for in @status['messages'] puts "\e[31m * #{Message.parse()}\e[0m" end end end |
#print_processes ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/procodile/status_cli_output.rb', line 42 def print_processes puts @status['processes'].each_with_index do |process, index| puts unless index == 0 puts "|| ".color(process['log_color']) + process['name'].color(process['log_color']) puts "||".color(process['log_color']) + " Quantity " + process['quantity'].to_s puts "||".color(process['log_color']) + " Command " + process['command'] puts "||".color(process['log_color']) + " Respawning " + "#{process['max_respawns']} every #{process['respawn_window']} seconds" puts "||".color(process['log_color']) + " Restart mode " + process['restart_mode'] puts "||".color(process['log_color']) + " Log path " + (process['log_path'] || "none specified") puts "||".color(process['log_color']) + " Address/Port " + (process['proxy_port'] ? "#{process['proxy_address']}:#{process['proxy_port']}" : "none") instances = @status['instances'][process['name']] if instances.empty? puts "||".color(process['log_color']) + " No processes running." else instances.each do |instance| print "|| => ".color(process['log_color']) + instance['description'].to_s.ljust(17, ' ').color(process['log_color']) print instance['status'].ljust(10, ' ') print " " + (instance['started_at']).ljust(10, ' ') print " pid:" + instance['pid'].to_s.ljust(6, ' ') print " respawns:" + instance['respawns'].to_s.ljust(4, ' ') print " port:" + (instance['port'] || "-").to_s.ljust(6, ' ') print " tag:" + (instance['tag'] || "-").to_s puts end end end end |