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.
- #kill ⇒ Object
- #restart ⇒ Object
- #start ⇒ Object
- #started? ⇒ Boolean
- #stop ⇒ Object
Constructor Details
#initialize(command) ⇒ Process
Returns a new instance of 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
39 40 41 42 43 |
# File 'lib/srv_manager/process.rb', line 39 def alive? started? && ::Process.kill(0, id) ? true : false rescue Errno::ESRCH false end |
#kill ⇒ Object
24 25 26 27 28 |
# File 'lib/srv_manager/process.rb', line 24 def kill send_signal 'KILL' LOGGER.info "Killed process #{@id}" @id = nil end |
#restart ⇒ Object
30 31 32 33 |
# File 'lib/srv_manager/process.rb', line 30 def restart stop if alive? start end |
#start ⇒ Object
11 12 13 14 15 16 |
# File 'lib/srv_manager/process.rb', line 11 def start return if alive? command.rvm ? rvm_start : default_start @id = wait_for_pid(command.pidfile) if command.pidfile LOGGER.info "Started process #{@id}" end |
#started? ⇒ Boolean
35 36 37 |
# File 'lib/srv_manager/process.rb', line 35 def started? !id.nil? end |
#stop ⇒ Object
18 19 20 21 22 |
# File 'lib/srv_manager/process.rb', line 18 def stop send_signal 'TERM' LOGGER.info "Stoped process #{@id}" @id = nil end |