From c1ee40ea3848e9489c02767a62b6ceba511b997c Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Mon, 29 Aug 2016 12:51:55 +0200 Subject: Disconnects all connections in the pool before forking. See discussion in https://github.com/puma/puma/issues/1001 --- railties/lib/rails/generators/rails/app/templates/config/puma.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'railties/lib/rails/generators') diff --git a/railties/lib/rails/generators/rails/app/templates/config/puma.rb b/railties/lib/rails/generators/rails/app/templates/config/puma.rb index 121ad7080e..a44bfbabec 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/puma.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/puma.rb @@ -42,6 +42,14 @@ environment ENV.fetch("RAILS_ENV") { "development" } # on_worker_boot do # ActiveRecord::Base.establish_connection if defined?(ActiveRecord) # end +# +# If you are preloading your application and using ActiveRecord, it's +# recommended that you close any connections to the database before workers +# are forked to prevent connection leakage. +# +# before_fork do +# ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord) +# end # Allow puma to be restarted by `rails restart` command. plugin :tmp_restart -- cgit v1.2.3