Method: Puma::DSL#before_fork

Defined in:
lib/puma/dsl.rb

#before_fork(&block) ⇒ Object

Note:

Cluster mode only.

Code to run immediately before master process forks workers (once on boot). These hooks can block if necessary to wait for background operations unknown to Puma to finish before the process terminates. This can be used to close any connections to remote servers (database, Redis, …) that were opened when preloading the code.

This can be called multiple times to add several hooks.

Examples:

before_fork do
  puts "Starting workers..."
end


736
737
738
# File 'lib/puma/dsl.rb', line 736

def before_fork(&block)
  process_hook :before_fork, nil, block, cluster_only: true
end