class Rush::ProcessSet
A container for processes that behaves like an array, and adds process-specific operations on the entire set, like kill.
Example:
processes.filter(:cmdline => /mongrel_rails/).kill
Attributes
processes[R]
Public Class Methods
new(processes)
click to toggle source
# File lib/rush/process_set.rb, line 11 def initialize(processes) @processes = processes end
Public Instance Methods
==(other)
click to toggle source
# File lib/rush/process_set.rb, line 50 def ==(other) if other.class == self.class other.processes == processes else to_a == other end end
alive?()
click to toggle source
Check status of all processes in the set, returns an array of booleans.
# File lib/rush/process_set.rb, line 40 def alive? processes.map { |p| p.alive? } end
each() { |p| ... }
click to toggle source
# File lib/rush/process_set.rb, line 46 def each processes.each { |p| yield p } end
filter(conditions)
click to toggle source
Filter by any field that the process responds to. Specify an exact value, or a regular expression. All conditions are put together as a boolean AND, so these two statements are equivalent:
processes.filter(:uid => 501).filter(:cmdline => /ruby/) processes.filter(:uid => 501, :cmdline => /ruby/)
# File lib/rush/process_set.rb, line 22 def filter(conditions) Rush::ProcessSet.new( processes.select do |p| conditions.all? do |key, value| value.class == Regexp ? value.match(p.send(key)) : p.send(key) == value end end ) end
kill(options={})
click to toggle source
Kill all processes in the set.
# File lib/rush/process_set.rb, line 35 def kill(options={}) processes.each { |p| p.kill(options) } end
method_missing(meth, *args)
click to toggle source
All other messages (like size or first) are passed through to the array.
# File lib/rush/process_set.rb, line 59 def method_missing(meth, *args) processes.send(meth, *args) end