Permalink
Browse files

bring heroku ps with release info

  • Loading branch information...
1 parent d3c1093 commit ead7a09e82c1eda4bfd72742e8b2d0120d37241f @pedro pedro committed Jan 24, 2013
Showing with 37 additions and 0 deletions.
  1. +1 −0 init.rb
  2. +36 −0 lib/heroku/ps.rb
View
@@ -1,3 +1,4 @@
$:.unshift(File.expand_path(File.join(Dir.getwd, "lib")))
require "heroku/deploy"
+require "heroku/ps"
View
@@ -0,0 +1,36 @@
+require "heroku/command/ps"
+
+class Heroku::Command::Ps
+ def index
+ validate_arguments!
+ processes = api.get_ps(app).body
+
+ processes_by_command = Hash.new {|hash,key| hash[key] = []}
+ processes.each do |process|
+ name = process["process"].split(".").first
+ elapsed = time_ago(Time.now - process['elapsed'])
+ release = "v#{process["release"]}"
+
+ if name == "run"
+ key = "run: one-off processes"
+ item = "%s: %s: %s `%s`" % [ process["process"], process["state"], release, elapsed, process["command"] ]
+ else
+ key = "#{name}: `#{process["command"]}`"
+ item = "%s: %s %s %s" % [ process["process"], process["state"], release, elapsed ]
+ end
+
+ processes_by_command[key] << item
+ end
+
+ processes_by_command.keys.each do |key|
+ processes_by_command[key] = processes_by_command[key].sort do |x,y|
+ x.match(/\.(\d+):/).captures.first.to_i <=> y.match(/\.(\d+):/).captures.first.to_i
+ end
+ end
+
+ processes_by_command.keys.sort.each do |key|
+ styled_header(key)
+ styled_array(processes_by_command[key], :sort => false)
+ end
+ end
+end

0 comments on commit ead7a09

Please sign in to comment.