Legacy code in puma config
janimo opened this issue · comments
According to this https://stackoverflow.com/questions/62458471/is-establish-connection-on-worker-boot-still-required-on-rails-6-and-puma
this snippet is no longer required in config/puma/defaults.rb
before_fork do
ActiveRecord::Base.connection_pool.disconnect!
end
on_worker_boot do
ActiveSupport.on_load(:active_record) do
ActiveRecord::Base.establish_connection
end
end
These are no longer included in the puma config generated by rails new ( as they were in v5.1)
Also as seen in the newer puma.rb files created by rails new, maybe the current per-environment files could be merged, and using RAILS_ENV, RAILS_MIN_THREADS, RAILS_MAX_THREADS,WEB_CONCURRENCY and an if would make the differences minimal.
Hi, @janimo 😄.
Thank you for reporting! Would you like to open a pull request removing the code that's no longer needed?
maybe the current per-environment files could be merged, and using RAILS_ENV, RAILS_MIN_THREADS, RAILS_MAX_THREADS,WEB_CONCURRENCY and an if would make the differences minimal.
Regarding staging.rb
, production.rb
and preproduction.rb
, there might be issues if we merge them together and rely on RAILS_ENV
🤔. For example, we manage Puma through systemd with something like systemctl --user start puma_consul_production
, and AFAIK the RAILS_ENV
variable isn't considered in this scenario with the Systemd file we use (which is the one provided by capistrano3-puma).
Regarding development.rb
, not sure whether it'd be worth unifying it because the file is small and the only duplicate line is plugin :tmp_restart
🤔. However, the situation can change if we introduce more duplication between development.rb
and defaults.rb
.