Class: RFlow::ChildProcess
- Inherits:
-
Object
- Object
- RFlow::ChildProcess
- Defined in:
- lib/rflow/child_process.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
Instance Method Summary collapse
-
#initialize(name, role = name) ⇒ ChildProcess
constructor
A new instance of ChildProcess.
- #run_child_process ⇒ Object
- #run_process ⇒ Object
- #shutdown!(signal) ⇒ Object
-
#spawn! ⇒ Object
Launch another process to execute the child.
Constructor Details
#initialize(name, role = name) ⇒ ChildProcess
Returns a new instance of ChildProcess.
7 8 9 10 |
# File 'lib/rflow/child_process.rb', line 7 def initialize(name, role = name) @name = name @role = role end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/rflow/child_process.rb', line 5 def name @name end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
5 6 7 |
# File 'lib/rflow/child_process.rb', line 5 def pid @pid end |
Instance Method Details
#run_child_process ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rflow/child_process.rb', line 27 def run_child_process @child_pipe_w.close register_logging_context update_process_name detach_process_group handle_signals RFlow.logger.info "#{@role} started" run_process exit 0 ensure unhandle_signals end |
#run_process ⇒ Object
41 |
# File 'lib/rflow/child_process.rb', line 41 def run_process; end |
#shutdown!(signal) ⇒ Object
43 44 45 46 |
# File 'lib/rflow/child_process.rb', line 43 def shutdown!(signal) RFlow.logger.info "Shutting down due to #{signal}" unhandle_signals end |
#spawn! ⇒ Object
Launch another process to execute the child. The parent process retains the original worker object (with pid and IPC pipe) to allow for process management
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rflow/child_process.rb', line 15 def spawn! establish_child_pipe drop_database_connections @pid = fork if @pid return_after_child_starts else run_child_process end end |