Class: Bluepill::ProcessFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/bluepill/dsl/process_factory.rb

Constant Summary collapse

@@process_keys =
{}
@@pid_files =
{}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes, process_block) ⇒ ProcessFactory

Returns a new instance of ProcessFactory.



8
9
10
11
# File 'lib/bluepill/dsl/process_factory.rb', line 8

def initialize(attributes, process_block)
  @attributes = attributes
  @process_block = process_block
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



3
4
5
# File 'lib/bluepill/dsl/process_factory.rb', line 3

def attributes
  @attributes
end

Instance Method Details

#create_child_process(name, pid, logger) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/bluepill/dsl/process_factory.rb', line 24

def create_child_process(name, pid, logger)
  attributes = {}
  [:start_grace_time, :stop_grace_time, :restart_grace_time].each { |a| attributes[a] = @attributes[a] }
  attributes[:actual_pid] = pid
  attributes[:logger] = logger

  child = ProcessProxy.new(name, attributes, @process_block)
  validate_child_process! child
  process = child.to_process

  process.determine_initial_state
  process
end

#create_process(name, pids_dir) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/bluepill/dsl/process_factory.rb', line 13

def create_process(name, pids_dir)
  assign_default_pid_file(name, pids_dir)

  process = ProcessProxy.new(name, @attributes, @process_block)
  child_process_block = @attributes.delete(:child_process_block)
  @attributes[:child_process_factory] = ProcessFactory.new(@attributes, child_process_block) if @attributes[:monitor_children]

  validate_process! process
  process.to_process
end