Module: Rabbit::Daemon

Extended by:
Daemon
Included in:
Daemon
Defined in:
lib/rabbit/daemon.rb

Instance Method Summary collapse

Instance Method Details

#configObject



39
40
41
# File 'lib/rabbit/daemon.rb', line 39

def config
  Rails.application.config_for("sneakers").symbolize_keys
end

#connectionObject



43
44
45
46
# File 'lib/rabbit/daemon.rb', line 43

def connection
  bunny_config = config.delete(:bunny_options).to_h.symbolize_keys
  Bunny.new(bunny_config)
end

#runObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/rabbit/daemon.rb', line 14

def run
  Sneakers.configure(
    connection: connection,
    env: Rails.env,
    exchange_type: :direct,
    exchange: Rabbit.config.app_name,
    hooks: Rabbit.config.hooks,
    supervisor: true,
    daemonize: false,
    exit_on_detach: true,
    **config,
  )

  Sneakers.logger = Logger.new(Rails.root.join("log", "sneakers.log"))
  Sneakers.logger.level = Logger::DEBUG
  Lamian.extend_logger(Sneakers.logger)

  Sneakers.server = true

  Rabbit.config.validate!
  Receiving::Worker.from_queue(Rabbit.config.read_queue)

  Sneakers::Runner.new([Receiving::Worker]).run
end