From e49ad8df9f0de227f3b1fe8715dee172870a7e39 Mon Sep 17 00:00:00 2001 From: Nick Charlton <nick@nickcharlton.net> Date: Thu, 11 Feb 2021 15:23:21 +0000 Subject: [PATCH] Update to Heroku's recommended Unicorn config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The prerelease app wasn't starting properly, with the config modifying some hashes …but the current recommended config doesn't have them at all. https://devcenter.heroku.com/articles/rails-unicorn --- config/unicorn.rb | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/config/unicorn.rb b/config/unicorn.rb index 555cf628..bebb93b0 100644 --- a/config/unicorn.rb +++ b/config/unicorn.rb @@ -1,30 +1,25 @@ # https://devcenter.heroku.com/articles/rails-unicorn -worker_processes (ENV["UNICORN_WORKERS"] || 3).to_i -timeout (ENV["UNICORN_TIMEOUT"] || 15).to_i +worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3) +timeout 15 preload_app true before_fork do |_server, _worker| Signal.trap "TERM" do - puts "Unicorn master intercepting TERM, sending myself QUIT instead" + puts "Unicorn master intercepting TERM and sending myself QUIT instead" Process.kill "QUIT", Process.pid end - if defined? ActiveRecord::Base + defined?(ActiveRecord::Base) && ActiveRecord::Base.connection.disconnect! - end end after_fork do |_server, _worker| Signal.trap "TERM" do - puts "Unicorn worker intercepting TERM, waiting for master to send QUIT" + puts "Unicorn worker intercepting TERM and doing nothing. " \ + "Wait for master to send QUIT" end - if defined? ActiveRecord::Base - config = ActiveRecord::Base.configurations[Rails.env] || - Rails.application.config.database_configuration[Rails.env] - config["reaping_frequency"] = (ENV["DB_REAPING_FREQUENCY"] || 10).to_i - config["pool"] = (ENV["DB_POOL"] || 2).to_i - ActiveRecord::Base.establish_connection(config) - end + defined?(ActiveRecord::Base) && + ActiveRecord::Base.establish_connection end -- GitLab