diff --git a/Gemfile b/Gemfile index 1844efe52..3cee01d6b 100644 --- a/Gemfile +++ b/Gemfile @@ -36,7 +36,7 @@ gem 'open-uri' gem 'paper_trail' gem 'pg', '~> 1.1' gem 'postmark-rails' -gem 'puma', '~> 6' +gem 'puma', '~> 7.2' gem 'rack-cors' gem 'rails', '~> 7.1' gem 'sentry-rails' diff --git a/Gemfile.lock b/Gemfile.lock index 61a798b02..f4985433c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -352,7 +352,7 @@ GEM date stringio public_suffix (6.0.2) - puma (6.6.1) + puma (7.2.0) nio4r (~> 2.0) raabro (1.4.0) racc (1.8.1) @@ -616,7 +616,7 @@ DEPENDENCIES pg (~> 1.1) postmark-rails pry-byebug - puma (~> 6) + puma (~> 7.2) rack-cors rails (~> 7.1) rails-erd diff --git a/config/puma.rb b/config/puma.rb index 1713441e5..71f0f48ff 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -26,20 +26,25 @@ # Specifies the `pidfile` that Puma will use. pidfile ENV.fetch('PIDFILE', 'tmp/pids/server.pid') -# Specifies the number of `workers` to boot in clustered mode. -# Workers are forked web server processes. If using threads and workers together -# the concurrency of the application would be max `threads` * `workers`. -# Workers do not work on JRuby or Windows (both of which do not support -# processes). -# -# workers ENV.fetch("WEB_CONCURRENCY") { 2 } +worker_count = ENV.fetch('WEB_CONCURRENCY', 1).to_i -# Use the `preload_app!` method when specifying a `workers` number. -# This directive tells Puma to first boot the application and load code -# before forking the application. This takes advantage of Copy On Write -# process behavior so workers use less memory. -# -# preload_app! +if worker_count > 1 + + # Specifies the number of `workers` to boot in clustered mode. + # Workers are forked web server processes. If using threads and workers together + # the concurrency of the application would be max `threads` * `workers`. + # Workers do not work on JRuby or Windows (both of which do not support + # processes). + + workers worker_count + + # Use the `preload_app!` method when specifying a `workers` number. + # This directive tells Puma to first boot the application and load code + # before forking the application. This takes advantage of Copy On Write + # process behavior so workers use less memory. + + preload_app! +end # Allow puma to be restarted by `bin/rails restart` command. plugin :tmp_restart