Class: Rush::Process
- Inherits:
-
Object
- Object
- Rush::Process
- Defined in:
- lib/rush/process.rb
Overview
An array of these objects is returned by Rush::Box#processes.
Instance Attribute Summary collapse
-
#box ⇒ Object
readonly
Returns the value of attribute box.
-
#cmdline ⇒ Object
readonly
Returns the value of attribute cmdline.
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#cpu ⇒ Object
readonly
Returns the value of attribute cpu.
-
#mem ⇒ Object
readonly
Returns the value of attribute mem.
-
#parent_pid ⇒ Object
readonly
Returns the value of attribute parent_pid.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
-
#uid ⇒ Object
readonly
Returns the value of attribute uid.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
-
#==(other) ⇒ Object
:nodoc:.
-
#alive? ⇒ Boolean
Returns true if the process is currently running.
-
#children ⇒ Object
Returns an array of child processes owned by this process.
-
#initialize(params, box) ⇒ Process
constructor
params is a hash returned by the system-specific method of looking up the process list.
-
#inspect ⇒ Object
:nodoc:.
-
#kill(options = {}) ⇒ Object
Terminate the process.
-
#parent ⇒ Object
Returns the Rush::Process parent of this process.
-
#to_s ⇒ Object
:nodoc:.
Constructor Details
#initialize(params, box) ⇒ Process
params is a hash returned by the system-specific method of looking up the process list.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/rush/process.rb', line 7 def initialize(params, box) @box = box @pid = params[:pid].to_i @uid = params[:uid].to_i @user = params[:user] @command = params[:command] @cmdline = params[:cmdline] @mem = params[:mem] @cpu = params[:cpu] @parent_pid = params[:parent_pid] end |
Instance Attribute Details
#box ⇒ Object (readonly)
Returns the value of attribute box.
3 4 5 |
# File 'lib/rush/process.rb', line 3 def box @box end |
#cmdline ⇒ Object (readonly)
Returns the value of attribute cmdline.
3 4 5 |
# File 'lib/rush/process.rb', line 3 def cmdline @cmdline end |
#command ⇒ Object (readonly)
Returns the value of attribute command.
3 4 5 |
# File 'lib/rush/process.rb', line 3 def command @command end |
#cpu ⇒ Object (readonly)
Returns the value of attribute cpu.
3 4 5 |
# File 'lib/rush/process.rb', line 3 def cpu @cpu end |
#mem ⇒ Object (readonly)
Returns the value of attribute mem.
3 4 5 |
# File 'lib/rush/process.rb', line 3 def mem @mem end |
#parent_pid ⇒ Object (readonly)
Returns the value of attribute parent_pid.
3 4 5 |
# File 'lib/rush/process.rb', line 3 def parent_pid @parent_pid end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
3 4 5 |
# File 'lib/rush/process.rb', line 3 def pid @pid end |
#uid ⇒ Object (readonly)
Returns the value of attribute uid.
3 4 5 |
# File 'lib/rush/process.rb', line 3 def uid @uid end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
3 4 5 |
# File 'lib/rush/process.rb', line 3 def user @user end |
Class Method Details
Instance Method Details
#==(other) ⇒ Object
:nodoc:
52 53 54 |
# File 'lib/rush/process.rb', line 52 def ==(other) # :nodoc: pid == other.pid and box == other.box end |
#alive? ⇒ Boolean
Returns true if the process is currently running.
43 44 45 |
# File 'lib/rush/process.rb', line 43 def alive? box.connection.process_alive(pid) end |
#children ⇒ Object
Returns an array of child processes owned by this process.
38 39 40 |
# File 'lib/rush/process.rb', line 38 def children box.processes.select { |p| p.parent_pid == pid } end |
#inspect ⇒ Object
:nodoc:
24 25 26 27 28 29 30 |
# File 'lib/rush/process.rb', line 24 def inspect # :nodoc: if box.to_s != 'localhost' "#{box} #{@pid}: #{@cmdline}" else "#{@pid}: #{@cmdline}" end end |
#kill(options = {}) ⇒ Object
Terminate the process.
48 49 50 |
# File 'lib/rush/process.rb', line 48 def kill(={}) box.connection.kill_process(pid, ) end |
#parent ⇒ Object
Returns the Rush::Process parent of this process.
33 34 35 |
# File 'lib/rush/process.rb', line 33 def parent box.processes.select { |p| p.pid == parent_pid }.first end |
#to_s ⇒ Object
:nodoc:
20 21 22 |
# File 'lib/rush/process.rb', line 20 def to_s # :nodoc: inspect end |