Class: Datacenter::Process
- Inherits:
-
Object
- Object
- Datacenter::Process
- Defined in:
- lib/datacenter/process.rb
Constant Summary collapse
- ATTRIBUTES =
[ :command, :status, :memory, :virtual_memory, :cpu, :user, :name, :cpu_usage, :mem_usage ]
Instance Attribute Summary collapse
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
Instance Method Summary collapse
- #alive? ⇒ Boolean
-
#initialize(pid, shell = nil) ⇒ Process
constructor
A new instance of Process.
- #send_signal(signal) ⇒ Object
Constructor Details
Instance Attribute Details
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
16 17 18 |
# File 'lib/datacenter/process.rb', line 16 def pid @pid end |
Instance Method Details
#alive? ⇒ Boolean
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/datacenter/process.rb', line 31 def alive? command = %Q{ if [ -d "#{proc_dir}" ]; then echo -n "true" else echo -n "false" fi } alive = shell.run(command) == 'true' Datacenter.logger.info(self.class) { "pid: #{pid} - ALIVE: #{alive}" } if !alive alive end |
#send_signal(signal) ⇒ Object
46 47 48 |
# File 'lib/datacenter/process.rb', line 46 def send_signal(signal) shell.run "kill -s #{signal} #{pid}" end |