Class: Procodile::Process

Inherits:
Object
  • Object
show all
Defined in:
lib/procodile/process.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options = {})
  @config = config
  @name = name
  @command = command
  @options = options
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



7
8
9
# File 'lib/procodile/process.rb', line 7

def command
  @command
end

#configObject (readonly)

Returns the value of attribute config.



8
9
10
# File 'lib/procodile/process.rb', line 8

def config
  @config
end

#nameObject (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_instancesObject

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_colorObject

Return the color for this process



20
21
22
# File 'lib/procodile/process.rb', line 20

def log_color
  @options['log_color'] || 0
end

#max_respawnsObject

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
  @options['max_respawns'] ? @options['max_respawns'].to_i : 5
end

#quantityObject

How many instances of this process should be started



27
28
29
# File 'lib/procodile/process.rb', line 27

def quantity
  @options['quantity'] || 1
end

#respawn_windowObject

The respawn window. One hour by default.



41
42
43
# File 'lib/procodile/process.rb', line 41

def respawn_window
  @options['respawn_window'] ? @options['respawn_window'].to_i : 3600
end

#restart_modeObject

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
  @options['restart_mode'] || 'term-start'
end