2
2
# are invoked here are part of Puma's configuration DSL. For more information
3
3
# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
4
4
5
- rails_env = ENV.fetch("RAILS_ENV", "development")
6
-
7
5
# Puma starts a configurable number of processes (workers) and each process
8
6
# serves each request in a thread from an internal thread pool.
9
7
#
@@ -25,7 +23,12 @@ rails_env = ENV.fetch("RAILS_ENV", "development")
25
23
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 3 }
26
24
threads threads_count, threads_count
27
25
28
- if rails_env == "production"
26
+ # Specifies the `environment` that Puma will run in.
27
+ rails_env = ENV.fetch("RAILS_ENV", "development")
28
+ environment rails_env
29
+
30
+ case rails_env
31
+ when "production"
29
32
# If you are running more than 1 thread per process, the workers count
30
33
# should be equal to the number of processors (CPU cores) in production.
31
34
#
@@ -36,21 +39,17 @@ if rails_env == "production"
36
39
workers workers_count if workers_count > 1
37
40
38
41
preload_app!
42
+ when "development"
43
+ # Specifies a very generous `worker_timeout` so that the worker
44
+ # isn't killed by Puma when suspended by a debugger.
45
+ worker_timeout 3600
39
46
end
40
47
41
48
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
42
49
port ENV.fetch("PORT") { 3000 }
43
50
44
- # Specifies the `environment` that Puma will run in.
45
- environment rails_env
46
-
47
51
# Allow puma to be restarted by `bin/rails restart` command.
48
52
plugin :tmp_restart
49
53
54
+ # Only use a pidfile when requested
50
55
pidfile ENV["PIDFILE"] if ENV["PIDFILE"]
51
-
52
- if rails_env == "development"
53
- # Specifies a very generous `worker_timeout` so that the worker
54
- # isn't killed by Puma when suspended by a debugger.
55
- worker_timeout 3600
56
- end
0 commit comments