Class: Procodile::Process
- Inherits:
-
Object
- Object
- Procodile::Process
- Defined in:
- lib/procodile/process.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#generate_instances ⇒ Object
Generate an array of new instances for this process (based on its quantity).
-
#initialize(config, name, command, options = {}) ⇒ Process
constructor
A new instance of Process.
-
#log_color ⇒ Object
Return the color for this process.
-
#max_respawns ⇒ Object
The maximum number of times this process can be respawned in the given period.
-
#quantity ⇒ Object
How many instances of this process should be started.
-
#respawn_window ⇒ Object
The respawn window.
-
#restart_mode ⇒ Object
Defines how this process should be restarted.
Constructor Details
#initialize(config, name, command, options = {}) ⇒ Process
10 11 12 13 14 15 |
# File 'lib/procodile/process.rb', line 10 def initialize(config, name, command, = {}) @config = config @name = name @command = command = end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
7 8 9 |
# File 'lib/procodile/process.rb', line 7 def command @command end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/procodile/process.rb', line 8 def config @config end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/procodile/process.rb', line 6 def name @name end |
Instance Method Details
#generate_instances ⇒ Object
Generate an array of new instances for this process (based on its quantity)
60 61 62 |
# File 'lib/procodile/process.rb', line 60 def generate_instances quantity.times.map { |i| Instance.new(self, i + 1) } end |
#log_color ⇒ Object
Return the color for this process
20 21 22 |
# File 'lib/procodile/process.rb', line 20 def log_color ['log_color'] || 0 end |
#max_respawns ⇒ Object
The maximum number of times this process can be respawned in the given period
34 35 36 |
# File 'lib/procodile/process.rb', line 34 def max_respawns ['max_respawns'] ? ['max_respawns'].to_i : 5 end |
#quantity ⇒ Object
How many instances of this process should be started
27 28 29 |
# File 'lib/procodile/process.rb', line 27 def quantity ['quantity'] || 1 end |
#respawn_window ⇒ Object
The respawn window. One hour by default.
41 42 43 |
# File 'lib/procodile/process.rb', line 41 def respawn_window ['respawn_window'] ? ['respawn_window'].to_i : 3600 end |
#restart_mode ⇒ Object
Defines how this process should be restarted
start-term = start new instances and send term to children usr1 = just send a usr1 signal to the current instance usr2 = just send a usr2 signal to the current instance term-start = stop the old instances, when no longer running, start a new one
53 54 55 |
# File 'lib/procodile/process.rb', line 53 def restart_mode ['restart_mode'] || 'term-start' end |