|
10 | 10 | min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } |
11 | 11 | threads min_threads_count, max_threads_count |
12 | 12 |
|
| 13 | +rails_env = ENV.fetch("RAILS_ENV", "development") |
| 14 | + |
13 | 15 | # Specifies the `worker_timeout` threshold that Puma will use to wait before |
14 | 16 | # terminating a worker in development environments. |
15 | 17 | # |
16 | | -worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" |
| 18 | +worker_timeout 3600 if rails_env == "development" |
17 | 19 |
|
18 | 20 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000. |
19 | 21 | # |
20 | 22 | port ENV.fetch("PORT", 3000) |
21 | 23 |
|
22 | 24 | # Specifies the `environment` that Puma will run in. |
23 | 25 | # |
24 | | -environment ENV.fetch("RAILS_ENV", "development") |
| 26 | +environment rails_env |
25 | 27 |
|
26 | 28 | # Specifies the `pidfile` that Puma will use. |
27 | 29 | pidfile ENV.fetch("PIDFILE", "tmp/pids/server.pid") |
28 | 30 |
|
29 | | -# Specifies the number of `workers` to boot in clustered mode. |
30 | | -# Workers are forked web server processes. If using threads and workers together |
31 | | -# the concurrency of the application would be max `threads` * `workers`. |
32 | | -# Workers do not work on JRuby or Windows (both of which do not support |
33 | | -# processes). |
34 | | -# |
35 | | -# workers ENV.fetch("WEB_CONCURRENCY") { 2 } |
36 | | - |
37 | | -# Use the `preload_app!` method when specifying a `workers` number. |
38 | | -# This directive tells Puma to first boot the application and load code |
39 | | -# before forking the application. This takes advantage of Copy On Write |
40 | | -# process behavior so workers use less memory. |
41 | | -# |
42 | | -# preload_app! |
| 31 | +if rails_env == "production" |
| 32 | + # Specifies the number of `workers` to boot in clustered mode. |
| 33 | + # Workers are forked web server processes. If using threads and workers together |
| 34 | + # the concurrency of the application would be max `threads` * `workers`. |
| 35 | + # Workers do not work on JRuby or Windows (both of which do not support |
| 36 | + # processes). |
| 37 | + # |
| 38 | + workers ENV.fetch("WEB_CONCURRENCY", 2) |
| 39 | + |
| 40 | + # Use the `preload_app!` method when specifying a `workers` number. |
| 41 | + # This directive tells Puma to first boot the application and load code |
| 42 | + # before forking the application. This takes advantage of Copy On Write |
| 43 | + # process behavior so workers use less memory. |
| 44 | + # |
| 45 | + preload_app! |
| 46 | + |
| 47 | + # Specifies the `worker_shutdown_timeout` threshold that Puma will use to wait before |
| 48 | + # terminating a worker. |
| 49 | + # |
| 50 | + worker_shutdown_timeout 60 |
| 51 | +end |
43 | 52 |
|
44 | 53 | # Allow puma to be restarted by `bin/rails restart` command. |
45 | 54 | plugin :tmp_restart |
0 commit comments