Class: RFlow::ChildProcess
- Inherits:
-
Object
- Object
- RFlow::ChildProcess
- Defined in:
- lib/rflow/child_process.rb
Direct Known Subclasses
Constant Summary collapse
- SIGINFO =
29
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.
9 10 11 12 |
# File 'lib/rflow/child_process.rb', line 9 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
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rflow/child_process.rb', line 29 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
43 |
# File 'lib/rflow/child_process.rb', line 43 def run_process; end |
#shutdown!(signal) ⇒ Object
45 46 47 48 |
# File 'lib/rflow/child_process.rb', line 45 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
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rflow/child_process.rb', line 17 def spawn! establish_child_pipe drop_database_connections @pid = fork if @pid return_after_child_starts else run_child_process end end |