Method: Unicorn::Configurator#after_fork

Defined in:
lib/unicorn/configurator.rb

#after_fork(*args, &block) ⇒ Object

sets after_fork hook to a given block. This block will be called by the worker after forking. The following is an example hook which adds a per-process listener to every worker:

after_fork do |server,worker|
  # per-process listener ports for debugging/admin:
  addr = "127.0.0.1:#{9293 + worker.nr}"

  # the negative :tries parameter indicates we will retry forever
  # waiting on the existing process to exit with a 5 second :delay
  # Existing options for Unicorn::Configurator#listen such as
  # :backlog, :rcvbuf, :sndbuf are available here as well.
  server.listen(addr, :tries => -1, :delay => 5, :backlog => 128)
end


166
167
168
# File 'lib/unicorn/configurator.rb', line 166

def after_fork(*args, &block)
  set_hook(:after_fork, block_given? ? block : args[0])
end