فهرست منبع

[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.
Petrik de Heus 2 ماه پیش
والد
کامیت
3330bcf112
1فایلهای تغییر یافته به همراه5 افزوده شده و 3 حذف شده
  1. 5 3
      frameworks/Ruby/rack/config/puma.rb

+ 5 - 3
frameworks/Ruby/rack/config/puma.rb

@@ -1,7 +1,7 @@
 require_relative 'auto_tune'
 
 # FWBM only... use the puma_auto_tune gem in production!
-_, num_threads = auto_tune
+num_workers, num_threads = auto_tune
 
 if RUBY_PLATFORM == 'java'
   num_threads = 512
@@ -10,6 +10,8 @@ end
 
 threads num_threads
 
-before_fork do
-  Sequel::DATABASES.each(&:disconnect)
+if num_workers > 0
+  before_fork do
+    Sequel::DATABASES.each(&:disconnect)
+  end
 end