Class: Shoryuken::Launcher
- Inherits:
-
Object
- Object
- Shoryuken::Launcher
- Includes:
- Util
- Defined in:
- lib/shoryuken/launcher.rb
Overview
Launches and coordinates Shoryuken’s message processing managers. Handles the lifecycle of the processing system including startup, shutdown, and health checks.
Instance Method Summary collapse
-
#healthy? ⇒ Boolean
Checks if all processing groups are healthy.
-
#initialize ⇒ Launcher
constructor
Initializes a new Launcher with managers for each processing group.
-
#start ⇒ void
Starts the message processing system.
-
#stop ⇒ void
Gracefully stops all processing, waiting for in-flight messages.
-
#stop! ⇒ void
Forces an immediate stop of all processing.
-
#stopping? ⇒ Boolean
Indicates whether the launcher is in the process of stopping.
Methods included from Util
#elapsed, #fire_event, #logger, #unparse_queues, #worker_name
Constructor Details
#initialize ⇒ Launcher
Initializes a new Launcher with managers for each processing group
10 11 12 13 |
# File 'lib/shoryuken/launcher.rb', line 10 def initialize @managers = create_managers @stopping = false end |
Instance Method Details
#healthy? ⇒ Boolean
Checks if all processing groups are healthy
73 74 75 76 77 78 |
# File 'lib/shoryuken/launcher.rb', line 73 def healthy? Shoryuken.groups.keys.all? do |group| manager = @managers.find { |m| m.group == group } manager && manager.running? end end |
#start ⇒ void
This method returns an undefined value.
Starts the message processing system
29 30 31 32 33 34 |
# File 'lib/shoryuken/launcher.rb', line 29 def start logger.info { 'Starting' } start_callback start_managers end |
#stop ⇒ void
This method returns an undefined value.
Gracefully stops all processing, waiting for in-flight messages
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/shoryuken/launcher.rb', line 55 def stop @stopping = true fire_event(:quiet, true) initiate_stop stop_new_dispatching await_dispatching_in_progress executor.shutdown executor.wait_for_termination fire_event(:stopped) end |
#stop! ⇒ void
This method returns an undefined value.
Forces an immediate stop of all processing
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/shoryuken/launcher.rb', line 39 def stop! @stopping = true initiate_stop # Don't await here so the timeout below is not delayed stop_new_dispatching executor.shutdown executor.kill unless executor.wait_for_termination(Shoryuken.[:timeout]) fire_event(:stopped) end |
#stopping? ⇒ Boolean
22 23 24 |
# File 'lib/shoryuken/launcher.rb', line 22 def stopping? @stopping end |