Class: Bluepill::ProcessFactory

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

Constant Summary collapse

@@process_keys =
Hash.new
@@pid_files =
Hash.new

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes, process_block) ⇒ ProcessFactory

Returns a new instance of ProcessFactory.



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

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

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



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

def attributes
  @attributes
end

Instance Method Details

#create_child_process(name, pid, logger) ⇒ Object



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

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)
  self.validate_child_process! child
  process = child.to_process

  process.determine_initial_state
  process
end

#create_process(name, pids_dir) ⇒ Object



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

def create_process(name, pids_dir)
  self.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]

  self.validate_process! process
  process.to_process
end