Class: EventedBluepill::ProcessFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/evented_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.



12
13
14
15
# File 'lib/evented_bluepill/dsl/process_factory.rb', line 12

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

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



7
8
9
# File 'lib/evented_bluepill/dsl/process_factory.rb', line 7

def attributes
  @attributes
end

Instance Method Details

#create_child_process(name, pid, logger) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/evented_bluepill/dsl/process_factory.rb', line 28

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 = EventedBluepill::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



17
18
19
20
21
22
23
24
25
26
# File 'lib/evented_bluepill/dsl/process_factory.rb', line 17

def create_process(name, pids_dir)
  self.assign_default_pid_file(name, pids_dir)
  
  process = EventedBluepill::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