From 30fd3a47ad34406f8f8169d0122493100b21ba8c Mon Sep 17 00:00:00 2001 From: Charlotte Van Petegem Date: Sat, 9 Nov 2024 12:09:56 +0100 Subject: [PATCH] Use puma in production --- Gemfile | 3 --- Gemfile.lock | 6 ------ config/puma.rb | 2 +- config/unicorn.rb | 24 ------------------------ server.dockerfile | 2 +- 5 files changed, 2 insertions(+), 35 deletions(-) delete mode 100644 config/unicorn.rb diff --git a/Gemfile b/Gemfile index 4c1a770..88614ba 100644 --- a/Gemfile +++ b/Gemfile @@ -12,9 +12,6 @@ gem 'propshaft' # Use postgresql as the database for Active Record gem 'pg', '~> 1.5' -# Use unicorn in production -gem 'unicorn', '~> 6.1' - # Bundle and process CSS [https://github.com/rails/cssbundling-rails] gem 'cssbundling-rails' diff --git a/Gemfile.lock b/Gemfile.lock index 1ebc95d..d2eeb7c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -155,7 +155,6 @@ GEM activesupport (>= 5.0.0) json (2.7.5) jwt (2.7.1) - kgio (2.11.4) language_server-protocol (3.17.0.3) logger (1.6.1) loofah (2.23.1) @@ -248,7 +247,6 @@ GEM thor (~> 1.0, >= 1.2.2) zeitwerk (~> 2.6) rainbow (3.1.1) - raindrops (0.20.1) rake (13.2.1) rdoc (6.7.0) psych (>= 4.0.0) @@ -305,9 +303,6 @@ GEM tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.6.0) - unicorn (6.1.0) - kgio (~> 2.6) - raindrops (~> 0.7) uri (1.0.1) useragent (0.16.10) web-console (4.2.1) @@ -352,7 +347,6 @@ DEPENDENCIES sentry-ruby solid_queue tzinfo-data - unicorn (~> 6.1) web-console webdrivers diff --git a/config/puma.rb b/config/puma.rb index ac65cb1..b37d8e0 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -28,7 +28,7 @@ # Allow puma to be restarted by `bin/rails restart` command. plugin :tmp_restart -plugin :solid_queue +plugin :solid_queue if ENV['SOLID_QUEUE_IN_PUMA'] # Only use a pidfile when requested pidfile ENV['PIDFILE'] if ENV['PIDFILE'] diff --git a/config/unicorn.rb b/config/unicorn.rb deleted file mode 100644 index 4563dde..0000000 --- a/config/unicorn.rb +++ /dev/null @@ -1,24 +0,0 @@ -worker_processes ENV['WORKER_PROCESSES'].to_i -listen ENV.fetch('LISTEN_ON', '0.0.0.0:3000') -timeout 30 -preload_app true -GC.respond_to?(:copy_on_write_friendly=) && GC.copy_on_write_friendly = true - -check_client_connection false - -before_fork do |server, worker| - defined?(ActiveRecord::Base) && ActiveRecord::Base.connection.disconnect! - - old_pid = "#{server.config[:pid]}.oldbin" - if old_pid != server.pid - begin - sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU - Process.kill(sig, File.read(old_pid).to_i) - rescue Errno::ENOENT, Errno::ESRCH - end - end -end - -after_fork do |_server, _worker| - defined?(ActiveRecord::Base) && ActiveRecord::Base.establish_connection -end diff --git a/server.dockerfile b/server.dockerfile index ef4beca..b6fcfaa 100644 --- a/server.dockerfile +++ b/server.dockerfile @@ -14,4 +14,4 @@ RUN bundle RUN bundle exec rails assets:precompile -CMD bundle exec rails db:prepare && bundle exec unicorn -c config/unicorn.rb +CMD bundle exec rails db:prepare && bundle exec rails server