Class: Karafka::Web::Tracking::Consumers::Listeners::Booting

Inherits:
Base
  • Object
show all
Defined in:
lib/karafka/web/tracking/consumers/listeners/booting.rb

Overview

Listener needed to start schedulers and other things that we need to collect and report data. We do not want to start this when code is loaded because it may not be fork compatible that way

Instance Method Summary collapse

Instance Method Details

#on_app_running(_event) ⇒ Object

Starts (if needed) the Web UI tracking scheduler thread that periodically pings reporters to report needed data (when it is time).

Parameters:

  • _event (Karafka::Core::Monitoring::Event)


16
17
18
# File 'lib/karafka/web/tracking/consumers/listeners/booting.rb', line 16

def on_app_running(_event)
  ::Karafka::Web.config.tracking.scheduler.async_call
end

#on_swarm_node_after_fork(_event) ⇒ Object

Updates the web producer after fork if needed and adds ppid to nodes

Parameters:

  • _event (Karafka::Core::Monitoring::Event)


22
23
24
25
26
27
28
# File 'lib/karafka/web/tracking/consumers/listeners/booting.rb', line 22

def on_swarm_node_after_fork(_event)
  ::Karafka::Process.tags.add(:node_ppid, "ppid:#{::Process.ppid}")

  return if Karafka::Web.config.producer == Karafka::App.config.producer

  Web.config.producer = Karafka::App.config.producer
end