Class: Aikido::Zen::Middleware::ForkDetector

Inherits:
Object
  • Object
show all
Defined in:
lib/aikido/zen/middleware/fork_detector.rb

Overview

This middleware is responsible for detecting when a process has forked (e.g., in a Puma or Unicorn worker) and resetting the state of the Aikido Zen agent. It should be inserted early in the middleware stack.

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ForkDetector

Returns a new instance of ForkDetector.



10
11
12
# File 'lib/aikido/zen/middleware/fork_detector.rb', line 10

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



14
15
16
17
18
19
# File 'lib/aikido/zen/middleware/fork_detector.rb', line 14

def call(env)
  # This is the single, reliable trigger point for the fork check.
  Aikido::Zen.check_and_handle_fork

  @app.call(env)
end