Class: Wurk::Swarm::ChildBoot
- Inherits:
-
Object
- Object
- Wurk::Swarm::ChildBoot
- Defined in:
- lib/wurk/swarm/child_boot.rb
Overview
Step 5 of the boot ordering. Runs inside each forked child:
* reset signal traps inherited from the parent,
* reconnect ActiveRecord (if loaded) + open a fresh Redis pool,
* apply the slot's queues + concurrency to the default capsule,
* install child signal handlers (TERM/INT drain, TSTP quiet,
USR2 reopen logs),
* launch the Wurk::Launcher and block until shutdown.
Kept separate from Wurk::Swarm so the parent supervisor stays focused on PID supervision (SRP).
Constant Summary collapse
- CHILD_SIGNALS =
{ 'TERM' => :term, 'INT' => :term, 'TSTP' => :tstp, 'USR2' => :usr2 }.freeze
Instance Method Summary collapse
-
#initialize(config, slot, index) ⇒ ChildBoot
constructor
A new instance of ChildBoot.
- #run ⇒ Object
Constructor Details
#initialize(config, slot, index) ⇒ ChildBoot
Returns a new instance of ChildBoot.
21 22 23 24 25 26 |
# File 'lib/wurk/swarm/child_boot.rb', line 21 def initialize(config, slot, index) @config = config @slot = slot @index = index @signal_queue = ::Thread::Queue.new end |
Instance Method Details
#run ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/wurk/swarm/child_boot.rb', line 28 def run reset_inherited_signals reconnect_after_fork Wurk.server = true apply_slot_to_config launcher = Wurk::Launcher.new(@config) install_signal_handlers(launcher) launcher.run wait_loop(launcher) exit 0 rescue StandardError, ::Wurk::Shutdown => e @config.logger.error { "swarm child ##{@index} (#{::Process.pid}) crashed: #{e.class}: #{e.}" } exit 1 end |