Class: Procodile::Process
- Inherits:
-
Object
- Object
- Procodile::Process
- Defined in:
- lib/procodile/process.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
Returns the value of attribute command.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#log_color ⇒ Object
Returns the value of attribute log_color.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#generate_instances(quantity = self.quantity, start_number = 1) ⇒ 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_path ⇒ Object
Return the path where log output for this process should be written to.
-
#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.
-
#term_signal ⇒ Object
Return the signal to send to terminate the process.
-
#to_hash ⇒ Object
Return a hash.
Constructor Details
#initialize(config, name, command, options = {}) ⇒ Process
Returns a new instance of Process.
12 13 14 15 16 17 18 |
# File 'lib/procodile/process.rb', line 12 def initialize(config, name, command, = {}) @config = config @name = name @command = command = @log_color = 0 end |
Instance Attribute Details
#command ⇒ Object
Returns the value of attribute command.
8 9 10 |
# File 'lib/procodile/process.rb', line 8 def command @command end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/procodile/process.rb', line 6 def config @config end |
#log_color ⇒ Object
Returns the value of attribute log_color.
10 11 12 |
# File 'lib/procodile/process.rb', line 10 def log_color @log_color end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/procodile/process.rb', line 7 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
9 10 11 |
# File 'lib/procodile/process.rb', line 9 def end |
Instance Method Details
#generate_instances(quantity = self.quantity, start_number = 1) ⇒ Object
Generate an array of new instances for this process (based on its quantity)
71 72 73 |
# File 'lib/procodile/process.rb', line 71 def generate_instances(quantity = self.quantity, start_number = 1) quantity.times.map { |i| Instance.new(self, i + start_number) } end |
#log_path ⇒ Object
Return the path where log output for this process should be written to. If none, output will be written to the supervisor log.
45 46 47 |
# File 'lib/procodile/process.rb', line 45 def log_path ['log_path'] ? File.(['log_path'], @config.root) : nil end |
#max_respawns ⇒ Object
The maximum number of times this process can be respawned in the given period
30 31 32 |
# File 'lib/procodile/process.rb', line 30 def max_respawns ['max_respawns'] ? ['max_respawns'].to_i : 5 end |
#quantity ⇒ Object
How many instances of this process should be started
23 24 25 |
# File 'lib/procodile/process.rb', line 23 def quantity ['quantity'] || 1 end |
#respawn_window ⇒ Object
The respawn window. One hour by default.
37 38 39 |
# File 'lib/procodile/process.rb', line 37 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
64 65 66 |
# File 'lib/procodile/process.rb', line 64 def restart_mode ['restart_mode'] || 'term-start' end |
#term_signal ⇒ Object
Return the signal to send to terminate the process
52 53 54 |
# File 'lib/procodile/process.rb', line 52 def term_signal ['term_signal'] || 'TERM' end |
#to_hash ⇒ Object
Return a hash
78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/procodile/process.rb', line 78 def to_hash { :name => self.name, :log_color => self.log_color, :quantity => self.quantity, :max_respawns => self.max_respawns, :respawn_window => self.respawn_window, :command => self.command, :restart_mode => self.restart_mode, :log_path => self.log_path } end |