From 1b6f3a2ef7de3c1d22123659504b100c418da872 Mon Sep 17 00:00:00 2001 From: Prathamesh Sonpatki Date: Wed, 14 Sep 2016 10:34:34 +0530 Subject: Move comment about disconnecting pool close to comment about preload - These two comments are connected to each other so kept them back to back. --- .../rails/generators/rails/app/templates/config/puma.rb | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 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 a44bfbabec..7ee948002e 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/puma.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/puma.rb @@ -32,6 +32,14 @@ environment ENV.fetch("RAILS_ENV") { "development" } # # preload_app! +# If you are preloading your application and using Active Record, 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 + # The code in the `on_worker_boot` will be called if you are using # clustered mode by specifying a number of `workers`. After each worker # process is booted this block will be run, if you are using `preload_app!` @@ -43,13 +51,6 @@ environment ENV.fetch("RAILS_ENV") { "development" } # 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