module Sqreen::WebServer

Public Instance Methods

attach() { || ... } click to toggle source
# File lib/sqreen/web_server.rb, line 19
def attach
  extend(detect)

  Sqreen.log.debug "[#{Process.pid}] #{detect.inspect}"

  if forking? && preload_app? && master?
    Sqreen.log.debug "[#{Process.pid}] master process #{Process.pid} delegating Sqreen worker boot to forked web worker processes"
    Sqreen.log.debug('Sqreen detected a forking web server with preloading')
    Sqreen.log.debug("master process #{Process.pid} delegating Sqreen worker boot to forked web worker processes")
    after_fork { yield }
  elsif forking? && !master? && !preload_app?
    Sqreen.log.debug "[#{Process.pid}] Booting Sqreen worker in process #{Process.pid}"
    Sqreen.log.debug('Sqreen detected a forked web worker without preloading')
    Sqreen.log.debug("Booting Sqreen worker in process #{Process.pid}")
    yield
  elsif !forking?
    Sqreen.log.debug "[#{Process.pid}] Booting Sqreen worker in process #{Process.pid}"
    Sqreen.log.debug('Sqreen detected a single-process web server')
    Sqreen.log.debug("Booting Sqreen worker in process #{Process.pid}")
    yield
  else
    Sqreen.log.debug "[#{Process.pid}] NOOP"
  end
end
detect() click to toggle source
# File lib/sqreen/web_server.rb, line 44
def detect
  [
    Sqreen::WebServer::Puma,
    Sqreen::WebServer::Rainbows,
    Sqreen::WebServer::Unicorn,
    Sqreen::WebServer::Passenger,
    Sqreen::WebServer::Thin,
    Sqreen::WebServer::WEBrick,
    Sqreen::WebServer::Generic,
  ].find(&:active?)
end