|
4 | 4 | # the maximum value specified for Puma. Default is set to 5 threads for minimum |
5 | 5 | # and maximum, this matches the default thread size of Active Record. |
6 | 6 | # |
| 7 | +root = File.expand_path("../..", __FILE__) |
| 8 | + |
7 | 9 | threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i |
8 | 10 | threads threads_count, threads_count |
9 | 11 |
|
10 | 12 | # Specifies the `port` that Puma will listen on to receive requests, default is 3000. |
11 | 13 | # |
12 | 14 | port ENV.fetch("PORT") { 3000 } |
13 | 15 |
|
| 16 | +# Set up socket location |
| 17 | +bind "unix://#{root}/tmp/sockets/puma.sock" |
| 18 | + |
| 19 | +# Logging |
| 20 | +# stdout_redirect "#{root}/log/puma.stdout.log", "#{root}/log/puma.stderr.log", true |
| 21 | + |
| 22 | +# Set master PID and state locations |
| 23 | +pidfile "#{root}/tmp/pids/puma.pid" |
| 24 | +state_path "#{root}/tmp/pids/puma.state" |
| 25 | +activate_control_app |
| 26 | + |
14 | 27 | # Specifies the `environment` that Puma will run in. |
15 | 28 | # |
16 | 29 | environment ENV.fetch("RAILS_ENV") { "development" } |
|
21 | 34 | # Workers do not work on JRuby or Windows (both of which do not support |
22 | 35 | # processes). |
23 | 36 | # |
24 | | -workers ENV.fetch("WEB_CONCURRENCY") { 2 } |
| 37 | +workers ENV.fetch("WEB_CONCURRENCY") { 5 } |
25 | 38 |
|
26 | 39 | # Use the `preload_app!` method when specifying a `workers` number. |
27 | 40 | # This directive tells Puma to first boot the application and load code |
|
38 | 51 | # option you will want to use this block to reconnect to any threads |
39 | 52 | # or connections that may have been created at application boot, Ruby |
40 | 53 | # cannot share connections between processes. |
41 | | -# |
42 | | -# on_worker_boot do |
43 | | -# ActiveRecord::Base.establish_connection if defined?(ActiveRecord) |
44 | | -# end |
| 54 | + |
| 55 | +on_worker_boot do |
| 56 | + ActiveRecord::Base.establish_connection if defined?(ActiveRecord) |
| 57 | +end |
45 | 58 |
|
46 | 59 | # Allow puma to be restarted by `rails restart` command. |
47 | 60 | plugin :tmp_restart |
0 commit comments