diff options
author | Francesco Rodriguez <frodsan@protonmail.com> | 2016-08-29 12:51:55 +0200 |
---|---|---|
committer | Francesco Rodriguez <frodsan@protonmail.com> | 2016-08-29 12:52:00 +0200 |
commit | c1ee40ea3848e9489c02767a62b6ceba511b997c (patch) | |
tree | 2870d17a33e4e80036c6a142412db9d3eb27a17c | |
parent | eab8c3b9c2b729fa0ba98ff21ad9f635a8391e87 (diff) | |
download | rails-c1ee40ea3848e9489c02767a62b6ceba511b997c.tar.gz rails-c1ee40ea3848e9489c02767a62b6ceba511b997c.tar.bz2 rails-c1ee40ea3848e9489c02767a62b6ceba511b997c.zip |
Disconnects all connections in the pool before forking.
See discussion in https://github.com/puma/puma/issues/1001
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/config/puma.rb | 8 |
1 files changed, 8 insertions, 0 deletions
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 |