Skip to content

Commit 3330bcf

Browse files
authored
[ruby/rack] Only add before_fork in multiple workers (#10146)
Fix the following warning: Warning: The code in the `before_fork` block will not execute in the current Puma configuration. The `before_fork` block only executes in Puma's cluster mode. To fix this, either remove the `before_fork` call or increase Puma's worker count above zero.
1 parent f20e287 commit 3330bcf

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require_relative 'auto_tune'
22

33
# FWBM only... use the puma_auto_tune gem in production!
4-
_, num_threads = auto_tune
4+
num_workers, num_threads = auto_tune
55

66
if RUBY_PLATFORM == 'java'
77
num_threads = 512
@@ -10,6 +10,8 @@
1010

1111
threads num_threads
1212

13-
before_fork do
14-
Sequel::DATABASES.each(&:disconnect)
13+
if num_workers > 0
14+
before_fork do
15+
Sequel::DATABASES.each(&:disconnect)
16+
end
1517
end

0 commit comments

Comments
 (0)