Files
grecia/config/puma/defaults.rb
Javi Martín d8d4c1e9a4 Use systemd to start and monitor puma
Puma 4 is no longer maintained, and Puma 5 removed the option to run
Puma as as daemon. That means that, in order to upgrade, we need to rely
in a process monitoring tool. We're using systemd because it's installed
by default in most (all?) operating systems running Consul Democracy on
production and it's supported by both Puma and the capistrano3-puma gem.

Using systemd means Puma will be automatically started whenever it
crashes, so we no longer need the changes done in commit 40b3c9f2c and
we can now use the default tasks configuration in capistrano3-puma and
capistrano3-delayed-job.

Since Puma is also started automatically when booting the system, we
don't need a cron job to do so anymore and can remove it from the
`schedule.rb` file.
2023-10-24 23:00:12 +02:00

36 lines
691 B
Ruby

#!/usr/bin/env puma
rails_root = File.expand_path("../../..", __FILE__)
directory rails_root
rackup "#{rails_root}/config.ru"
tag ""
pidfile "#{rails_root}/tmp/pids/puma.pid"
state_path "#{rails_root}/tmp/pids/puma.state"
stdout_redirect "#{rails_root}/log/puma_access.log", "#{rails_root}/log/puma_error.log", true
bind "unix://#{rails_root}/tmp/sockets/puma.sock"
threads 0, 16
workers 2
preload_app!
plugin :tmp_restart
on_restart do
puts "Refreshing Gemfile"
ENV["BUNDLE_GEMFILE"] = ""
end
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