Skip to content

Instantly share code, notes, and snippets.

@jrochkind
Created February 1, 2017 19:48
Show Gist options
  • Save jrochkind/99b96429783754dc1810d922364922e8 to your computer and use it in GitHub Desktop.
Save jrochkind/99b96429783754dc1810d922364922e8 to your computer and use it in GitHub Desktop.
threads Integer(ENV['PUMA_MIN_THREADS'] || 16), Integer(ENV['PUMA_MAX_THREADS'] || 16)
preload_app!
port ENV['PORT'] || 3000
environment ENV['RACK_ENV'] || 'development'
workers Integer(ENV['PUMA_WORKERS'] || 3)
before_fork do
if defined?(::ActiveRecord) && defined?(::ActiveRecord::Base)
ActiveRecord::Base.connection_pool.disconnect!
end
end
on_worker_boot do
ActiveSupport.on_load(:active_record) do
config = ActiveRecord::Base.configurations[Rails.env] ||
Rails.application.config.database_configuration[Rails.env]
config['pool'] = ENV['PUMA_MAX_THREADS'] || 16
ActiveRecord::Base.establish_connection(config)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment