Skip to content

Commit c77c126

Browse files
committed
7.1.4
1 parent df6c9de commit c77c126

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ source "https://rubygems.org"
33
ruby "your-ruby-version"
44

55
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
6-
gem "rails", "~> 7.1.3", ">= 7.1.3.4"
6+
gem "rails", "~> 7.1.4"
77

88
# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
99
gem "sprockets-rails"
1010

1111
# Use sqlite3 as the database for Active Record
12-
gem "sqlite3", "~> 1.4"
12+
gem "sqlite3", ">= 1.4"
1313

1414
# Use the Puma web server [https://github.com/puma/puma]
1515
gem "puma", ">= 5.0"

config/puma.rb

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,22 @@
1111
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
1212
threads min_threads_count, max_threads_count
1313

14-
# Specifies that the worker count should equal the number of processors in production.
15-
if ENV["RAILS_ENV"] == "production"
16-
require "concurrent-ruby"
17-
worker_count = Integer(ENV.fetch("WEB_CONCURRENCY") { Concurrent.physical_processor_count })
18-
workers worker_count if worker_count > 1
19-
end
14+
rails_env = ENV.fetch("RAILS_ENV") { "development" }
2015

16+
if rails_env == "production"
17+
# If you are running more than 1 thread per process, the workers count
18+
# should be equal to the number of processors (CPU cores) in production.
19+
#
20+
# It defaults to 1 because it's impossible to reliably detect how many
21+
# CPU cores are available. Make sure to set the `WEB_CONCURRENCY` environment
22+
# variable to match the number of processors.
23+
worker_count = Integer(ENV.fetch("WEB_CONCURRENCY") { 1 })
24+
if worker_count > 1
25+
workers worker_count
26+
else
27+
preload_app!
28+
end
29+
end
2130
# Specifies the `worker_timeout` threshold that Puma will use to wait before
2231
# terminating a worker in development environments.
2332
worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
@@ -26,7 +35,7 @@
2635
port ENV.fetch("PORT") { 3000 }
2736

2837
# Specifies the `environment` that Puma will run in.
29-
environment ENV.fetch("RAILS_ENV") { "development" }
38+
environment rails_env
3039

3140
# Specifies the `pidfile` that Puma will use.
3241
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }

0 commit comments

Comments
 (0)