class Rookout::ForkManager

Public Class Methods

new() click to toggle source
# File lib/rookout/atfork.rb, line 6
def initialize
  @active = false
end

Public Instance Methods

activate!() click to toggle source
# File lib/rookout/atfork.rb, line 10
def activate!
  @active = true
end
active?() click to toggle source
# File lib/rookout/atfork.rb, line 18
def active?
  @active
end
disable!() click to toggle source
# File lib/rookout/atfork.rb, line 14
def disable!
  @active = false
end
fork_hook(original_fork) { || ... } click to toggle source
# File lib/rookout/atfork.rb, line 22
def fork_hook original_fork
  if block_given?
    original_fork.call do
      post_fork_child if active?
      yield
    end
  else
    res = original_fork.call
    post_fork_child if active? && !res
    res
  end
end
post_fork_child() click to toggle source
# File lib/rookout/atfork.rb, line 35
def post_fork_child
  require_relative "rookout_singleton"
  require_relative "interface"

  RookoutSingleton.instance.post_fork_clean
  Interface.instance.stop
  Interface.instance.start post_fork: true

  # Disable fork handler in child process
  disable!
end