Class: Eventboss::Runner

Inherits:
Object
  • Object
show all
Extended by:
Logging
Defined in:
lib/eventboss/runner.rb

Class Method Summary collapse

Methods included from Logging

logger

Class Method Details

.launchObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/eventboss/runner.rb', line 8

def launch
  queues = Eventboss::QueueListener.select(
    include: Eventboss.configuration.listeners[:include],
    exclude: Eventboss.configuration.listeners[:exclude]
  )
  client = Eventboss.configuration.sqs_client
  config = Eventboss.configuration

  Eventboss::Instrumentation.add(queues)

  launcher = Launcher.new(queues, client, worker_count: config.concurrency)

  self_read = setup_signals([:SIGTERM])

  logger.info('Active listeners:')
  queues.each { |queue, listener| logger.info("#{queue}: #{listener}") }

  Eventboss::DevelopmentMode.setup_infrastructure(queues) if config.development_mode?

  begin
    launcher.start
    handle_signals(self_read, launcher)
  rescue Interrupt
    launcher.stop
    exit 0
  end
end