class Shoryuken::Launcher

Public Class Methods

new() click to toggle source
# File lib/shoryuken/launcher.rb, line 5
def initialize
  @managers = create_managers
end

Public Instance Methods

healthy?() click to toggle source
# File lib/shoryuken/launcher.rb, line 35
def healthy?
  Shoryuken.groups.keys.all? do |group|
    manager = @managers.find { |m| m.group == group }
    manager && manager.running?
  end
end
start() click to toggle source
# File lib/shoryuken/launcher.rb, line 9
def start
  logger.info { 'Starting' }

  start_callback
  start_managers
end
stop() click to toggle source
# File lib/shoryuken/launcher.rb, line 26
def stop
  fire_event(:quiet, true)

  initiate_stop

  executor.shutdown
  executor.wait_for_termination
end
stop!() click to toggle source
# File lib/shoryuken/launcher.rb, line 16
def stop!
  initiate_stop

  executor.shutdown

  return if executor.wait_for_termination(Shoryuken.options[:timeout])

  executor.kill
end

Private Instance Methods

create_managers() click to toggle source
# File lib/shoryuken/launcher.rb, line 78
def create_managers
  Shoryuken.groups.map do |group, options|
    Shoryuken::Manager.new(
      group,
      Shoryuken::Fetcher.new(group),
      Shoryuken.polling_strategy(group).new(options[:queues], Shoryuken.delay(group)),
      options[:concurrency],
      executor
    )
  end
end
executor() click to toggle source
# File lib/shoryuken/launcher.rb, line 44
def executor
  @_executor ||= Shoryuken.launcher_executor || Concurrent.global_io_executor
end
initiate_stop() click to toggle source
# File lib/shoryuken/launcher.rb, line 54
def initiate_stop
  logger.info { 'Shutting down' }

  stop_callback
end
start_callback() click to toggle source
# File lib/shoryuken/launcher.rb, line 60
def start_callback
  if (callback = Shoryuken.start_callback)
    logger.debug { 'Calling start_callback' }
    callback.call
  end

  fire_event(:startup)
end
start_managers() click to toggle source
# File lib/shoryuken/launcher.rb, line 48
def start_managers
  @managers.each do |manager|
    Concurrent::Future.execute { manager.start }
  end
end
stop_callback() click to toggle source
# File lib/shoryuken/launcher.rb, line 69
def stop_callback
  if (callback = Shoryuken.stop_callback)
    logger.debug { 'Calling stop_callback' }
    callback.call
  end

  fire_event(:shutdown, true)
end