Class: Foreman::Process
- Inherits:
-
Object
- Object
- Foreman::Process
- Defined in:
- lib/foreman/process.rb
Instance Attribute Summary collapse
-
#entry ⇒ Object
readonly
Returns the value of attribute entry.
-
#num ⇒ Object
readonly
Returns the value of attribute num.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
- #alive? ⇒ Boolean
- #dead? ⇒ Boolean
- #detach ⇒ Object
-
#initialize(entry, num, port) ⇒ Process
constructor
A new instance of Process.
- #kill(signal) ⇒ Object
- #name ⇒ Object
- #run(pipe, basedir, environment) ⇒ Object
Constructor Details
#initialize(entry, num, port) ⇒ Process
Returns a new instance of Process.
11 12 13 14 15 |
# File 'lib/foreman/process.rb', line 11 def initialize(entry, num, port) @entry = entry @num = num @port = port end |
Instance Attribute Details
#entry ⇒ Object (readonly)
Returns the value of attribute entry.
6 7 8 |
# File 'lib/foreman/process.rb', line 6 def entry @entry end |
#num ⇒ Object (readonly)
Returns the value of attribute num.
7 8 9 |
# File 'lib/foreman/process.rb', line 7 def num @num end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
8 9 10 |
# File 'lib/foreman/process.rb', line 8 def pid @pid end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
9 10 11 |
# File 'lib/foreman/process.rb', line 9 def port @port end |
Instance Method Details
#alive? ⇒ Boolean
37 38 39 |
# File 'lib/foreman/process.rb', line 37 def alive? kill(0) end |
#dead? ⇒ Boolean
41 42 43 |
# File 'lib/foreman/process.rb', line 41 def dead? !alive? end |
#detach ⇒ Object
33 34 35 |
# File 'lib/foreman/process.rb', line 33 def detach pid && Process.detach(pid) end |
#kill(signal) ⇒ Object
27 28 29 30 31 |
# File 'lib/foreman/process.rb', line 27 def kill(signal) pid && Process.kill(signal, pid) rescue Errno::ESRCH false end |
#name ⇒ Object
23 24 25 |
# File 'lib/foreman/process.rb', line 23 def name "%s.%s" % [ entry.name, num ] end |
#run(pipe, basedir, environment) ⇒ Object
17 18 19 20 21 |
# File 'lib/foreman/process.rb', line 17 def run(pipe, basedir, environment) with_environment(environment.merge("PORT" => port.to_s)) do run_process basedir, entry.command, pipe end end |