|
11 | 11 | min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
|
12 | 12 | threads min_threads_count, max_threads_count
|
13 | 13 |
|
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" } |
20 | 15 |
|
| 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 |
21 | 30 | # Specifies the `worker_timeout` threshold that Puma will use to wait before
|
22 | 31 | # terminating a worker in development environments.
|
23 | 32 | worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
|
|
26 | 35 | port ENV.fetch("PORT") { 3000 }
|
27 | 36 |
|
28 | 37 | # Specifies the `environment` that Puma will run in.
|
29 | | -environment ENV.fetch("RAILS_ENV"){"development"} |
| 38 | +environment rails_env |
30 | 39 |
|
31 | 40 | # Specifies the `pidfile` that Puma will use.
|
32 | 41 | pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
|
|
0 commit comments