Class: EventedBluepill::ProcessFactory
- Inherits:
-
Object
- Object
- EventedBluepill::ProcessFactory
- Defined in:
- lib/evented_bluepill/dsl/process_factory.rb
Constant Summary collapse
- @@process_keys =
Hash.new
- @@pid_files =
Hash.new
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
- #create_child_process(name, pid, logger) ⇒ Object
- #create_process(name, pids_dir) ⇒ Object
-
#initialize(attributes, process_block) ⇒ ProcessFactory
constructor
A new instance of ProcessFactory.
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
#attributes ⇒ Object (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 |