فهرست منبع

[ruby/roda] Let Puma decide the number of workers (#10119)

Petrik de Heus 3 ماه پیش
والد
کامیت
037b691a1e

+ 1 - 0
frameworks/Ruby/roda-sequel/Gemfile

@@ -6,6 +6,7 @@ gem "sequel", "~> 5.67"
 gem "roda", "~> 3.66"
 gem "roda", "~> 3.66"
 gem "tilt", "~> 2.1", require: "tilt/erb"
 gem "tilt", "~> 2.1", require: "tilt/erb"
 gem "cgi" # Make sure the h plugin uses the faster CGI.escape_html
 gem "cgi" # Make sure the h plugin uses the faster CGI.escape_html
+gem "concurrent-ruby"
 
 
 group :mysql, optional: true do
 group :mysql, optional: true do
   gem 'trilogy', '~> 2.9', platforms: [:ruby, :windows]
   gem 'trilogy', '~> 2.9', platforms: [:ruby, :windows]

+ 2 - 0
frameworks/Ruby/roda-sequel/Gemfile.lock

@@ -3,6 +3,7 @@ GEM
   specs:
   specs:
     bigdecimal (3.1.9)
     bigdecimal (3.1.9)
     cgi (0.5.0)
     cgi (0.5.0)
+    concurrent-ruby (1.3.5)
     erubi (1.13.1)
     erubi (1.13.1)
     iodine (0.7.58)
     iodine (0.7.58)
     json (2.13.2)
     json (2.13.2)
@@ -28,6 +29,7 @@ PLATFORMS
 
 
 DEPENDENCIES
 DEPENDENCIES
   cgi
   cgi
+  concurrent-ruby
   erubi (~> 1.12)
   erubi (~> 1.12)
   iodine (~> 0.7)
   iodine (~> 0.7)
   json (~> 2.8)
   json (~> 2.8)

+ 6 - 3
frameworks/Ruby/roda-sequel/config/mri_puma.rb

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

+ 1 - 0
frameworks/Ruby/roda-sequel/roda-sequel-postgres.dockerfile

@@ -16,6 +16,7 @@ RUN bundle install --jobs=8
 
 
 ENV DBTYPE=postgresql
 ENV DBTYPE=postgresql
 
 
+ENV WEB_CONCURRENCY=auto
 EXPOSE 8080
 EXPOSE 8080
 
 
 CMD bundle exec puma -C config/mri_puma.rb -b tcp://0.0.0.0:8080 -e production
 CMD bundle exec puma -C config/mri_puma.rb -b tcp://0.0.0.0:8080 -e production

+ 1 - 0
frameworks/Ruby/roda-sequel/roda-sequel.dockerfile

@@ -17,6 +17,7 @@ RUN bundle install --jobs=8
 
 
 ENV DBTYPE=mysql
 ENV DBTYPE=mysql
 
 
+ENV WEB_CONCURRENCY=auto
 EXPOSE 8080
 EXPOSE 8080
 
 
 CMD bundle exec puma -C config/mri_puma.rb -b tcp://0.0.0.0:8080 -e production
 CMD bundle exec puma -C config/mri_puma.rb -b tcp://0.0.0.0:8080 -e production