Class: Bluepill::ProcessFactory
- Inherits:
-
Object
- Object
- Bluepill::ProcessFactory
- Defined in:
- lib/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.
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
#attributes ⇒ Object (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 |