Module: Beacon::Railtie::ForkHook

Defined in:
lib/beacon/rails.rb

Overview

Ruby 3.1+ Process._fork hook. Runs in every fork child, which is exactly what we want — the first push in a new worker would re-init anyway via Client#ensure_forked!, but this makes it eager so the flusher is already running when the first request lands.

Instance Method Summary collapse

Instance Method Details

#_forkObject



165
166
167
168
169
170
171
172
173
174
175
# File 'lib/beacon/rails.rb', line 165

def _fork
  pid = super
  if pid == 0
    begin
      Beacon.client.after_fork
    rescue => e
      warn "[beacon] after_fork hook rescued #{e.class}: #{e.message}"
    end
  end
  pid
end