Class: SrvManager::Process
- Inherits:
-
Object
- Object
- SrvManager::Process
- Defined in:
- lib/srv_manager/process.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #alive? ⇒ Boolean
-
#initialize(command) ⇒ Process
constructor
A new instance of Process.
- #restart ⇒ Object
- #start ⇒ Object
- #started? ⇒ Boolean
- #stop ⇒ Object
Constructor Details
#initialize(command) ⇒ Process
7 8 9 |
# File 'lib/srv_manager/process.rb', line 7 def initialize(command) @command = command end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
4 5 6 |
# File 'lib/srv_manager/process.rb', line 4 def command @command end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/srv_manager/process.rb', line 5 def id @id end |
Instance Method Details
#alive? ⇒ Boolean
36 37 38 39 40 |
# File 'lib/srv_manager/process.rb', line 36 def alive? started? && ::Process.kill(0, id) ? true : false rescue Errno::ESRCH false end |
#restart ⇒ Object
27 28 29 30 |
# File 'lib/srv_manager/process.rb', line 27 def restart stop if alive? start end |
#start ⇒ Object
11 12 13 14 15 |
# File 'lib/srv_manager/process.rb', line 11 def start return if alive? command.rvm ? rvm_start : default_start LOGGER.info "Started process #{@id}" end |
#started? ⇒ Boolean
32 33 34 |
# File 'lib/srv_manager/process.rb', line 32 def started? !id.nil? end |
#stop ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/srv_manager/process.rb', line 17 def stop return unless started? begin ::Process.kill 'TERM', @id rescue Errno::ESRCH end LOGGER.info "Stoped process #{@id}" @id = nil end |