Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Status in one line

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4299 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit de69de10ded1c0d124f974f995ce31fd68b774d2 1 parent 4a218de
@dhh dhh authored
Showing with 8 additions and 9 deletions.
  1. +8 −9 railties/lib/commands/process/inspector.rb
View
17 railties/lib/commands/process/inspector.rb
@@ -5,7 +5,7 @@
OPTIONS = {
:pid_path => File.expand_path(RAILS_ROOT + '/tmp/pids'),
:pattern => "dispatch.*.pid",
- :ps => "ps -o user,start,etime,pcpu,vsz,majflt,command -p %s"
+ :ps => "ps -o pid,state,user,start,time,pcpu,vsz,majflt,command -p %s"
}
class Inspector
@@ -18,17 +18,16 @@ def initialize(pid_path, pattern)
end
def inspect
- for process in find_processes
- puts "#{File.basename(process[:pid_file])}:"
- puts(`#{OPTIONS[:ps] % process[:pid]}`)
- puts
- end
+ header = `#{OPTIONS[:ps] % 0}`.split("\n")[0] + "\n"
+ lines = pids.collect { |pid| `#{OPTIONS[:ps] % pid}`.split("\n")[1] }
+
+ puts(header + lines.join("\n"))
end
private
- def find_processes
- pid_files.inject([]) do |pids, pid_file|
- pids << { :pid_file => pid_file, :pid => File.read(pid_file).to_i }
+ def pids
+ pid_files.collect do |pid_file|
+ File.read(pid_file).to_i
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.