2014-09-02 18:07:02 +05:30
|
|
|
worker_processes 2
|
2015-04-26 12:48:37 +05:30
|
|
|
timeout 60
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
preload_app true
|
|
|
|
check_client_connection false
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
before_fork do |server, worker|
|
2018-11-18 11:00:15 +05:30
|
|
|
# the following is highly recommended for Rails + "preload_app true"
|
|
|
|
# as there's no need for the master process to hold a connection
|
|
|
|
defined?(ActiveRecord::Base) and
|
|
|
|
ActiveRecord::Base.connection.disconnect!
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
if /darwin/ =~ RUBY_PLATFORM
|
|
|
|
require 'fiddle'
|
|
|
|
|
|
|
|
# Dynamically load Foundation.framework, ~implicitly~ initialising
|
|
|
|
# the Objective-C runtime before any forking happens in Unicorn
|
|
|
|
#
|
|
|
|
# From https://bugs.ruby-lang.org/issues/14009
|
|
|
|
Fiddle.dlopen '/System/Library/Frameworks/Foundation.framework/Foundation'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
after_fork do |server, worker|
|
|
|
|
# Unicorn clears out signals before it forks, so rbtrace won't work
|
|
|
|
# unless it is enabled after the fork.
|
|
|
|
require 'rbtrace' if ENV['ENABLE_RBTRACE']
|
|
|
|
|
|
|
|
# the following is *required* for Rails + "preload_app true",
|
|
|
|
defined?(ActiveRecord::Base) and
|
|
|
|
ActiveRecord::Base.establish_connection
|
|
|
|
end
|