Jelajahi Sumber

Rails: Upgrade to 6.1.3 (#6394)

* Upgrade to ruby 3 and 6.1

* update rails to 6.1.2.1

* db pool doesn't need to be bigger than the number of puma threads

* rails 6 automatically establishes the pool

* consistent quotes

* update to rails 6.1

* remove middlewares not required for this benchmark

* Gem lock files are a good thing

* oj does have a small but positive effect

* I suppose I'm an expert

* update mysql dockerfile

* remove excess boilerplate

* include rails bin

Co-authored-by: Nate <[email protected]>
Michael Spiz 4 tahun lalu
induk
melakukan
76179bad70
36 mengubah file dengan 493 tambahan dan 571 penghapusan
  1. 1 67
      .gitignore
  2. 9 16
      frameworks/Ruby/rails/Gemfile
  3. 158 0
      frameworks/Ruby/rails/Gemfile.lock
  4. 4 5
      frameworks/Ruby/rails/README.md
  5. 1 1
      frameworks/Ruby/rails/Rakefile
  6. 20 5
      frameworks/Ruby/rails/app/controllers/hello_world_controller.rb
  7. 7 25
      frameworks/Ruby/rails/benchmark_config.json
  8. 114 0
      frameworks/Ruby/rails/bin/bundle
  9. 4 0
      frameworks/Ruby/rails/bin/rails
  10. 4 0
      frameworks/Ruby/rails/bin/rake
  11. 2 1
      frameworks/Ruby/rails/config.ru
  12. 6 19
      frameworks/Ruby/rails/config.toml
  13. 25 2
      frameworks/Ruby/rails/config/application.rb
  14. 1 1
      frameworks/Ruby/rails/config/boot.rb
  15. 7 9
      frameworks/Ruby/rails/config/database.yml
  16. 1 1
      frameworks/Ruby/rails/config/environment.rb
  17. 15 7
      frameworks/Ruby/rails/config/environments/development.rb
  18. 14 24
      frameworks/Ruby/rails/config/environments/production.rb
  19. 16 8
      frameworks/Ruby/rails/config/environments/test.rb
  20. 0 8
      frameworks/Ruby/rails/config/initializers/application_controller_renderer.rb
  21. 4 3
      frameworks/Ruby/rails/config/initializers/backtrace_silencers.rb
  22. 0 25
      frameworks/Ruby/rails/config/initializers/content_security_policy.rb
  23. 3 1
      frameworks/Ruby/rails/config/initializers/filter_parameter_logging.rb
  24. 0 16
      frameworks/Ruby/rails/config/initializers/inflections.rb
  25. 0 4
      frameworks/Ruby/rails/config/initializers/mime_types.rb
  26. 0 14
      frameworks/Ruby/rails/config/initializers/wrap_parameters.rb
  27. 0 33
      frameworks/Ruby/rails/config/locales/en.yml
  28. 0 28
      frameworks/Ruby/rails/config/mri_puma.rb
  29. 0 158
      frameworks/Ruby/rails/config/nginx.conf
  30. 49 0
      frameworks/Ruby/rails/config/puma.rb
  31. 1 0
      frameworks/Ruby/rails/config/routes.rb
  32. 0 59
      frameworks/Ruby/rails/config/unicorn.rb
  33. 16 0
      frameworks/Ruby/rails/rails-mysql.dockerfile
  34. 0 13
      frameworks/Ruby/rails/rails-postgresql.dockerfile
  35. 0 14
      frameworks/Ruby/rails/rails-unicorn.dockerfile
  36. 11 4
      frameworks/Ruby/rails/rails.dockerfile

+ 1 - 67
.gitignore

@@ -60,70 +60,4 @@ benchmark.cfg
 .*.sw[a-p]
 
 # merge tooling
-*.orig
-
-# maven
-*.versionsBackup
-*.releaseBackup
-
-# python-isms
-*.pyc
-
-# java / ruby stuff
-*.lock
-*.war
-
-# go
-go/pkg/*
-beego/pkg/*
-
-# urweb
-frameworks/Ur/urweb/*.exe
-
-# nim
-nimcache
-
-# crystal
-.crystal
-*.out
-
-#don't ignore merge request templates
-!.github/
-dependency-reduced-pom.xml
-
-# dart
-.dart_tool/
-*.packages
-pubspec.lock
-
-# Gradle
-.gradle/
-build/
-
-# haskell
-.stack-work
-
-# Elixir
-_build/
-deps/
-frameworks/PHP/ubiquity/.buildpath
-
-# swift
-Package.resolved
-.swiftpm
-DerivedData
-.build
-
-#fsharp
-launchSettings.json
-.vs
-obj
-[Bb]in/
-[Oo]bj/
-[Dd]ebug/
-[Rr]elease/
-*.fsproj.user
-
-# CFML
-frameworks/CFML/coldbox/src/coldbox/
-frameworks/CFML/CFML/src/cachebox/
+*.orig

+ 9 - 16
frameworks/Ruby/rails/Gemfile

@@ -1,16 +1,9 @@
-source 'http://rubygems.org'
-
-gem 'unicorn', '5.4.1'
-gem 'puma', '3.12.6'
-gem 'activerecord', '5.2.2', :require => 'active_record'
-gem 'rails', '5.2.2'
-gem 'tzinfo-data', '1.2018.7'
-gem 'oj', '3.7.9'
-
-group :mysql do
-  gem 'mysql2', '0.5.2'
-end
-
-group :postgresql do
-  gem 'pg', '1.1.4'
-end
+source 'https://rubygems.org' do
+  gem 'listen', '~> 3.3', group: :development
+  gem 'mysql2', '0.5.3', group: :mysql
+  gem 'oj', '3.11.2'
+  gem 'pg', '1.2.3', group: :postgresql
+  gem 'puma', '5.2.1'
+  gem 'rails', '6.1.3'
+  gem 'tzinfo-data', '1.2021.1'
+end

+ 158 - 0
frameworks/Ruby/rails/Gemfile.lock

@@ -0,0 +1,158 @@
+GEM
+  remote: https://rubygems.org/
+  specs:
+    actioncable (6.1.3)
+      actionpack (= 6.1.3)
+      activesupport (= 6.1.3)
+      nio4r (~> 2.0)
+      websocket-driver (>= 0.6.1)
+    actionmailbox (6.1.3)
+      actionpack (= 6.1.3)
+      activejob (= 6.1.3)
+      activerecord (= 6.1.3)
+      activestorage (= 6.1.3)
+      activesupport (= 6.1.3)
+      mail (>= 2.7.1)
+    actionmailer (6.1.3)
+      actionpack (= 6.1.3)
+      actionview (= 6.1.3)
+      activejob (= 6.1.3)
+      activesupport (= 6.1.3)
+      mail (~> 2.5, >= 2.5.4)
+      rails-dom-testing (~> 2.0)
+    actionpack (6.1.3)
+      actionview (= 6.1.3)
+      activesupport (= 6.1.3)
+      rack (~> 2.0, >= 2.0.9)
+      rack-test (>= 0.6.3)
+      rails-dom-testing (~> 2.0)
+      rails-html-sanitizer (~> 1.0, >= 1.2.0)
+    actiontext (6.1.3)
+      actionpack (= 6.1.3)
+      activerecord (= 6.1.3)
+      activestorage (= 6.1.3)
+      activesupport (= 6.1.3)
+      nokogiri (>= 1.8.5)
+    actionview (6.1.3)
+      activesupport (= 6.1.3)
+      builder (~> 3.1)
+      erubi (~> 1.4)
+      rails-dom-testing (~> 2.0)
+      rails-html-sanitizer (~> 1.1, >= 1.2.0)
+    activejob (6.1.3)
+      activesupport (= 6.1.3)
+      globalid (>= 0.3.6)
+    activemodel (6.1.3)
+      activesupport (= 6.1.3)
+    activerecord (6.1.3)
+      activemodel (= 6.1.3)
+      activesupport (= 6.1.3)
+    activestorage (6.1.3)
+      actionpack (= 6.1.3)
+      activejob (= 6.1.3)
+      activerecord (= 6.1.3)
+      activesupport (= 6.1.3)
+      marcel (~> 0.3.1)
+      mimemagic (~> 0.3.2)
+    activesupport (6.1.3)
+      concurrent-ruby (~> 1.0, >= 1.0.2)
+      i18n (>= 1.6, < 2)
+      minitest (>= 5.1)
+      tzinfo (~> 2.0)
+      zeitwerk (~> 2.3)
+    builder (3.2.4)
+    concurrent-ruby (1.1.8)
+    crass (1.0.6)
+    erubi (1.10.0)
+    ffi (1.14.2)
+    globalid (0.4.2)
+      activesupport (>= 4.2.0)
+    i18n (1.8.9)
+      concurrent-ruby (~> 1.0)
+    listen (3.4.1)
+      rb-fsevent (~> 0.10, >= 0.10.3)
+      rb-inotify (~> 0.9, >= 0.9.10)
+    loofah (2.9.0)
+      crass (~> 1.0.2)
+      nokogiri (>= 1.5.9)
+    mail (2.7.1)
+      mini_mime (>= 0.1.1)
+    marcel (0.3.3)
+      mimemagic (~> 0.3.2)
+    method_source (1.0.0)
+    mimemagic (0.3.5)
+    mini_mime (1.0.2)
+    minitest (5.14.3)
+    mysql2 (0.5.3)
+    nio4r (2.5.5)
+    nokogiri (1.11.1-arm64-darwin)
+      racc (~> 1.4)
+    oj (3.11.2)
+    pg (1.2.3)
+    puma (5.2.1)
+      nio4r (~> 2.0)
+    racc (1.5.2)
+    rack (2.2.3)
+    rack-test (1.1.0)
+      rack (>= 1.0, < 3)
+    rails (6.1.3)
+      actioncable (= 6.1.3)
+      actionmailbox (= 6.1.3)
+      actionmailer (= 6.1.3)
+      actionpack (= 6.1.3)
+      actiontext (= 6.1.3)
+      actionview (= 6.1.3)
+      activejob (= 6.1.3)
+      activemodel (= 6.1.3)
+      activerecord (= 6.1.3)
+      activestorage (= 6.1.3)
+      activesupport (= 6.1.3)
+      bundler (>= 1.15.0)
+      railties (= 6.1.3)
+      sprockets-rails (>= 2.0.0)
+    rails-dom-testing (2.0.3)
+      activesupport (>= 4.2.0)
+      nokogiri (>= 1.6)
+    rails-html-sanitizer (1.3.0)
+      loofah (~> 2.3)
+    railties (6.1.3)
+      actionpack (= 6.1.3)
+      activesupport (= 6.1.3)
+      method_source
+      rake (>= 0.8.7)
+      thor (~> 1.0)
+    rake (13.0.3)
+    rb-fsevent (0.10.4)
+    rb-inotify (0.10.1)
+      ffi (~> 1.0)
+    sprockets (4.0.2)
+      concurrent-ruby (~> 1.0)
+      rack (> 1, < 3)
+    sprockets-rails (3.2.2)
+      actionpack (>= 4.0)
+      activesupport (>= 4.0)
+      sprockets (>= 3.0.0)
+    thor (1.1.0)
+    tzinfo (2.0.4)
+      concurrent-ruby (~> 1.0)
+    tzinfo-data (1.2021.1)
+      tzinfo (>= 1.0.0)
+    websocket-driver (0.7.3)
+      websocket-extensions (>= 0.1.0)
+    websocket-extensions (0.1.5)
+    zeitwerk (2.4.2)
+
+PLATFORMS
+  arm64-darwin-20
+
+DEPENDENCIES
+  listen (~> 3.3)!
+  mysql2 (= 0.5.3)!
+  oj (= 3.11.2)!
+  pg (= 1.2.3)!
+  puma (= 5.2.1)!
+  rails (= 6.1.3)!
+  tzinfo-data (= 1.2021.1)!
+
+BUNDLED WITH
+   2.2.7

+ 4 - 5
frameworks/Ruby/rails/README.md

@@ -12,10 +12,9 @@ comparing a variety of web platforms.
 
 The tests were run with:
 
-- [Ruby 2.6.0](http://www.ruby-lang.org/)
-- [Rails 5.2.2](http://rubyonrails.org/)
-- [Unicorn 5.4.1](http://unicorn.bogomips.org/)
-- [Puma 3.12](http://puma.io/)
+- [Ruby 3.0.0](http://www.ruby-lang.org/)
+- [Rails 6.1.3](http://rubyonrails.org/)
+- [Puma 5.2.1](http://puma.io/)
 - [MySQL 5.5](https://dev.mysql.com/)
 - [PostgreSQL 11](https://www.postgresql.org/)
 
@@ -32,7 +31,7 @@ The tests were run with:
 
 ### Experts
 
-_No experts listed, yet. If you're an expert, add yourself!_
+@spizm
 
 ### Community
 

+ 1 - 1
frameworks/Ruby/rails/Rakefile

@@ -1,6 +1,6 @@
 # Add your own tasks in files placed in lib/tasks ending in .rake,
 # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
 
-require_relative 'config/application'
+require_relative "config/application"
 
 Rails.application.load_tasks

+ 20 - 5
frameworks/Ruby/rails/app/controllers/hello_world_controller.rb

@@ -1,6 +1,8 @@
 # frozen_string_literal: true
 
 class HelloWorldController < ApplicationController
+  QUERY_RANGE = (1..10_000).to_a
+
   def plaintext
     render plain: 'Hello, World!'
   end
@@ -10,7 +12,7 @@ class HelloWorldController < ApplicationController
   end
 
   def db
-    render json: World.find(Random.rand(1..10000))
+    render json: World.find(Random.rand(1..10_000))
   end
 
   def query
@@ -18,8 +20,7 @@ class HelloWorldController < ApplicationController
     queries = 1 if queries < 1
     queries = 500 if queries > 500
 
-    numbers = (1..10000).to_a.sample(queries)
-    results = numbers.map do |id|
+    results = QUERY_RANGE.sample(queries).map do |id|
       World.find(id)
     end
 
@@ -29,7 +30,7 @@ class HelloWorldController < ApplicationController
   def fortune
     @fortunes = Fortune.all.to_a
     @fortunes << Fortune.new(id: 0, message: 'Additional fortune added at request time.')
-    @fortunes = @fortunes.sort_by(&:message)
+    @fortunes = @fortunes.sort_by!(&:message)
   end
 
   def update
@@ -42,7 +43,7 @@ class HelloWorldController < ApplicationController
       # rows with ids 1 - 10000
       world = World.select(:id, :randomNumber).find(id)
       begin
-        rn = Random.rand(1..10000)
+        rn = Random.rand(1..10_000)
       end while rn == world.randomNumber
       world.update_column(:randomNumber, rn)
       world
@@ -50,4 +51,18 @@ class HelloWorldController < ApplicationController
 
     render json: worlds
   end
+
+  def cached_query
+    queries = params[:queries].to_i
+    queries = 1 if queries < 1
+    queries = 500 if queries > 500
+
+    results = QUERY_RANGE.sample(queries).map do |id|
+      Rails.cache.fetch("world-#{id}") do
+        World.find(id)
+      end
+    end
+
+    render json: results
+  end
 end

+ 7 - 25
frameworks/Ruby/rails/benchmark_config.json

@@ -2,32 +2,13 @@
   "framework": "rails",
   "tests": [{
     "default": {
-      "json_url": "/json",
       "db_url": "/db",
+      "json_url": "/json",
       "query_url": "/queries?queries=",
       "fortune_url": "/fortunes",
       "update_url": "/updates?queries=",
       "plaintext_url": "/plaintext",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Fullstack",
-      "database": "MySQL",
-      "framework": "rails",
-      "language": "Ruby",
-      "orm": "Full",
-      "platform": "Rack",
-      "webserver": "Puma",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "rails-puma-mri",
-      "notes": "",
-      "versus": "rack-puma-mri"
-    },
-    "postgresql": {
-      "db_url": "/db",
-      "query_url": "/queries?queries=",
-      "fortune_url": "/fortunes",
-      "update_url": "/updates?queries=",
+      "cached_query_url": "/cached?queries=",
       "port": 8080,
       "approach": "Realistic",
       "classification": "Fullstack",
@@ -43,13 +24,14 @@
       "notes": "",
       "versus": ""
     },
-    "unicorn": {
+    "mysql": {
       "json_url": "/json",
       "db_url": "/db",
       "query_url": "/queries?queries=",
       "fortune_url": "/fortunes",
       "update_url": "/updates?queries=",
       "plaintext_url": "/plaintext",
+      "cached_query_url": "/cached?queries=",
       "port": 8080,
       "approach": "Realistic",
       "classification": "Fullstack",
@@ -58,12 +40,12 @@
       "language": "Ruby",
       "orm": "Full",
       "platform": "Rack",
-      "webserver": "Unicorn",
+      "webserver": "Puma",
       "os": "Linux",
       "database_os": "Linux",
-      "display_name": "rails-unicorn-mri",
+      "display_name": "rails-mysql",
       "notes": "",
-      "versus": "rack-unicorn-mri"
+      "versus": "rack-puma-mri"
     }
   }]
 }

+ 114 - 0
frameworks/Ruby/rails/bin/bundle

@@ -0,0 +1,114 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+#
+# This file was generated by Bundler.
+#
+# The application 'bundle' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require "rubygems"
+
+m = Module.new do
+  module_function
+
+  def invoked_as_script?
+    File.expand_path($0) == File.expand_path(__FILE__)
+  end
+
+  def env_var_version
+    ENV["BUNDLER_VERSION"]
+  end
+
+  def cli_arg_version
+    return unless invoked_as_script? # don't want to hijack other binstubs
+    return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
+    bundler_version = nil
+    update_index = nil
+    ARGV.each_with_index do |a, i|
+      if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
+        bundler_version = a
+      end
+      next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
+      bundler_version = $1
+      update_index = i
+    end
+    bundler_version
+  end
+
+  def gemfile
+    gemfile = ENV["BUNDLE_GEMFILE"]
+    return gemfile if gemfile && !gemfile.empty?
+
+    File.expand_path("../../Gemfile", __FILE__)
+  end
+
+  def lockfile
+    lockfile =
+      case File.basename(gemfile)
+      when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
+      else "#{gemfile}.lock"
+      end
+    File.expand_path(lockfile)
+  end
+
+  def lockfile_version
+    return unless File.file?(lockfile)
+    lockfile_contents = File.read(lockfile)
+    return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
+    Regexp.last_match(1)
+  end
+
+  def bundler_version
+    @bundler_version ||=
+      env_var_version || cli_arg_version ||
+        lockfile_version
+  end
+
+  def bundler_requirement
+    return "#{Gem::Requirement.default}.a" unless bundler_version
+
+    bundler_gem_version = Gem::Version.new(bundler_version)
+
+    requirement = bundler_gem_version.approximate_recommendation
+
+    return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
+
+    requirement += ".a" if bundler_gem_version.prerelease?
+
+    requirement
+  end
+
+  def load_bundler!
+    ENV["BUNDLE_GEMFILE"] ||= gemfile
+
+    activate_bundler
+  end
+
+  def activate_bundler
+    gem_error = activation_error_handling do
+      gem "bundler", bundler_requirement
+    end
+    return if gem_error.nil?
+    require_error = activation_error_handling do
+      require "bundler/version"
+    end
+    return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
+    warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
+    exit 42
+  end
+
+  def activation_error_handling
+    yield
+    nil
+  rescue StandardError, LoadError => e
+    e
+  end
+end
+
+m.load_bundler!
+
+if m.invoked_as_script?
+  load Gem.bin_path("bundler", "bundle")
+end

+ 4 - 0
frameworks/Ruby/rails/bin/rails

@@ -0,0 +1,4 @@
+#!/usr/bin/env ruby
+APP_PATH = File.expand_path('../config/application', __dir__)
+require_relative "../config/boot"
+require "rails/commands"

+ 4 - 0
frameworks/Ruby/rails/bin/rake

@@ -0,0 +1,4 @@
+#!/usr/bin/env ruby
+require_relative "../config/boot"
+require "rake"
+Rake.application.run

+ 2 - 1
frameworks/Ruby/rails/config.ru

@@ -1,5 +1,6 @@
 # This file is used by Rack-based servers to start the application.
 
-require_relative 'config/environment'
+require_relative "config/environment"
 
 run Rails.application
+Rails.application.load_server

+ 6 - 19
frameworks/Ruby/rails/config.toml

@@ -1,13 +1,14 @@
 [framework]
 name = "rails"
 
-[main]
+[mysql]
 urls.plaintext = "/plaintext"
 urls.json = "/json"
 urls.db = "/db"
 urls.query = "/queries?queries="
 urls.update = "/updates?queries="
 urls.fortune = "/fortunes"
+urls.cached_query = "/cached?queries="
 approach = "Realistic"
 classification = "Fullstack"
 database = "MySQL"
@@ -19,33 +20,19 @@ webserver = "Puma"
 versus = "rack-puma-mri"
 
 [postgresql]
-urls.db = "/db"
-urls.query = "/queries?queries="
-urls.update = "/updates?queries="
-urls.fortune = "/fortunes"
-approach = "Realistic"
-classification = "Fullstack"
-database = "Postgres"
-database_os = "Linux"
-os = "Linux"
-orm = "Full"
-platform = "Rack"
-webserver = "Puma"
-versus = ""
-
-[unicorn]
 urls.plaintext = "/plaintext"
 urls.json = "/json"
 urls.db = "/db"
 urls.query = "/queries?queries="
 urls.update = "/updates?queries="
 urls.fortune = "/fortunes"
+urls.cached_query = "/cached?queries="
 approach = "Realistic"
 classification = "Fullstack"
-database = "MySQL"
+database = "Postgres"
 database_os = "Linux"
 os = "Linux"
 orm = "Full"
 platform = "Rack"
-webserver = "Unicorn"
-versus = "rack-unicorn-mri"
+webserver = "Puma"
+versus = "rack-puma-mri"

+ 25 - 2
frameworks/Ruby/rails/config/application.rb

@@ -1,4 +1,4 @@
-require_relative 'boot'
+require_relative "boot"
 
 require "rails"
 # Pick the frameworks you want:
@@ -20,7 +20,7 @@ Bundler.require(*Rails.groups)
 module Hello
   class Application < Rails::Application
     # Initialize configuration defaults for originally generated Rails version.
-    config.load_defaults 5.2
+    config.load_defaults 6.1
 
     # Settings in config/environments/* take precedence over those specified here.
     # Application configuration can go into files in config/initializers
@@ -28,5 +28,28 @@ module Hello
     # the framework and any gems in your application.
 
     config.action_dispatch.default_headers.merge!('Server' => 'WebServer')
+
+    config.middleware.delete ActionDispatch::HostAuthorization
+    config.middleware.delete Rack::Sendfile
+    config.middleware.delete ActionDispatch::Static
+    config.middleware.delete ActionDispatch::Executor
+    config.middleware.delete Rack::Runtime
+    config.middleware.delete Rack::MethodOverride
+    config.middleware.delete ActionDispatch::RequestId
+    config.middleware.delete ActionDispatch::RemoteIp
+    config.middleware.delete Rails::Rack::Logger
+    config.middleware.delete ActionDispatch::ShowExceptions
+    config.middleware.delete ActionDispatch::DebugExceptions
+    config.middleware.delete ActionDispatch::ActionableExceptions
+    config.middleware.delete ActionDispatch::Reloader
+    config.middleware.delete ActiveRecord::Migration::CheckPending
+    config.middleware.delete ActionDispatch::Cookies
+    config.middleware.delete ActionDispatch::Session::CookieStore
+    config.middleware.delete ActionDispatch::Flash
+    config.middleware.delete ActionDispatch::ContentSecurityPolicy::Middleware
+    config.middleware.delete ActionDispatch::PermissionsPolicy::Middleware
+    config.middleware.delete Rack::Head
+    config.middleware.delete Rack::ConditionalGet
+    config.middleware.delete Rack::ETag
   end
 end

+ 1 - 1
frameworks/Ruby/rails/config/boot.rb

@@ -1,3 +1,3 @@
 ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
 
-require 'bundler/setup' # Set up gems listed in the Gemfile.
+require "bundler/setup" # Set up gems listed in the Gemfile.

+ 7 - 9
frameworks/Ruby/rails/config/database.yml

@@ -1,25 +1,23 @@
 ---
-_: &common
+default: &default
   database: hello_world
   username: benchmarkdbuser
   password: benchmarkdbpass
   host: tfb-database
   timeout: 5000
+  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
 
 development:
-  <<: *common
-  pool: 5
+  <<: *default
 
 test:
-  <<: *common
-  pool: 64
+  <<: *default
 
 production_mysql:
-  <<: *common
+  <<: *default
   adapter: mysql2
-  pool: 64
 
 production_postgresql:
-  <<: *common
+  <<: *default
   adapter: postgresql
-  pool: 64
+  encoding: unicode

+ 1 - 1
frameworks/Ruby/rails/config/environment.rb

@@ -1,5 +1,5 @@
 # Load the Rails application.
-require_relative 'application'
+require_relative "application"
 
 # Initialize the Rails application.
 Rails.application.initialize!

+ 15 - 7
frameworks/Ruby/rails/config/environments/development.rb

@@ -1,8 +1,10 @@
+require "active_support/core_ext/integer/time"
+
 Rails.application.configure do
   # Settings specified here will take precedence over those in config/application.rb.
 
-  # In the development environment your application's code is reloaded on
-  # every request. This slows down response time but is perfect for development
+  # In the development environment your application's code is reloaded any time
+  # it changes. This slows down response time but is perfect for development
   # since you don't have to restart the web server when you make code changes.
   config.cache_classes = false
 
@@ -16,6 +18,7 @@ Rails.application.configure do
   # Run rails dev:cache to toggle caching.
   if Rails.root.join('tmp', 'caching-dev.txt').exist?
     config.action_controller.perform_caching = true
+    config.action_controller.enable_fragment_cache_logging = true
 
     config.cache_store = :memory_store
     config.public_file_server.headers = {
@@ -30,17 +33,22 @@ Rails.application.configure do
   # Print deprecation notices to the Rails logger.
   config.active_support.deprecation = :log
 
+  # Raise exceptions for disallowed deprecations.
+  config.active_support.disallowed_deprecation = :raise
+
+  # Tell Active Support which deprecation messages to disallow.
+  config.active_support.disallowed_deprecation_warnings = []
+
   # Raise an error on page load if there are pending migrations.
   config.active_record.migration_error = :page_load
 
   # Highlight code that triggered database queries in logs.
   config.active_record.verbose_query_logs = true
 
-
-  # Raises error for missing translations
-  # config.action_view.raise_on_missing_translations = true
-
   # Use an evented file watcher to asynchronously detect changes in source code,
   # routes, locales, etc. This feature depends on the listen gem.
   config.file_watcher = ActiveSupport::EventedFileUpdateChecker
-end
+
+  # Uncomment if you wish to allow Action Cable access from any origin.
+  # config.action_cable.disable_request_forgery_protection = true
+end

+ 14 - 24
frameworks/Ruby/rails/config/environments/production.rb

@@ -1,3 +1,5 @@
+require "active_support/core_ext/integer/time"
+
 Rails.application.configure do
   # Settings specified here will take precedence over those in config/application.rb.
 
@@ -14,37 +16,19 @@ Rails.application.configure do
   config.consider_all_requests_local       = false
   config.action_controller.perform_caching = true
 
-  # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
-  # or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
-  # config.require_master_key = true
-
   # Disable serving static files from the `/public` folder by default since
   # Apache or NGINX already handles this.
   config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
 
-  # Enable serving of images, stylesheets, and JavaScripts from an asset server.
-  # config.action_controller.asset_host = 'http://assets.example.com'
-
-  # Specifies the header that your server uses for sending files.
-  # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
-  # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
-
-  # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
-  # config.force_ssl = true
-
-  # Use the lowest log level to ensure availability of diagnostic information
-  # when problems arise.
-  config.log_level = :error
+  # Include generic and useful information about system operation, but avoid logging too much
+  # information to avoid inadvertent exposure of personally identifiable information (PII).
+  config.log_level = :info
 
   # Prepend all log lines with the following tags.
   config.log_tags = [ :request_id ]
 
   # Use a different cache store in production.
-  # config.cache_store = :mem_cache_store
-
-  # Use a real queuing backend for Active Job (and separate queues per environment)
-  # config.active_job.queue_adapter     = :resque
-  # config.active_job.queue_name_prefix = "testrails522_#{Rails.env}"
+  config.cache_store = :memory_store
 
   # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
   # the I18n.default_locale when a translation cannot be found).
@@ -53,11 +37,17 @@ Rails.application.configure do
   # Send deprecation notices to registered listeners.
   config.active_support.deprecation = :notify
 
+  # Log disallowed deprecations.
+  config.active_support.disallowed_deprecation = :log
+
+  # Tell Active Support which deprecation messages to disallow.
+  config.active_support.disallowed_deprecation_warnings = []
+
   # Use default logging formatter so that PID and timestamp are not suppressed.
   config.log_formatter = ::Logger::Formatter.new
 
   # Use a different logger for distributed setups.
-  # require 'syslog/logger'
+  # require "syslog/logger"
   # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
 
   if ENV["RAILS_LOG_TO_STDOUT"].present?
@@ -68,4 +58,4 @@ Rails.application.configure do
 
   # Do not dump schema after migrations.
   config.active_record.dump_schema_after_migration = false
-end
+end

+ 16 - 8
frameworks/Ruby/rails/config/environments/test.rb

@@ -1,11 +1,15 @@
+require "active_support/core_ext/integer/time"
+
+# The test environment is used exclusively to run your application's
+# test suite. You never need to work with it otherwise. Remember that
+# your test database is "scratch space" for the test suite and is wiped
+# and recreated between test runs. Don't rely on the data there!
+
 Rails.application.configure do
   # Settings specified here will take precedence over those in config/application.rb.
 
-  # The test environment is used exclusively to run your application's
-  # test suite. You never need to work with it otherwise. Remember that
-  # your test database is "scratch space" for the test suite and is wiped
-  # and recreated between test runs. Don't rely on the data there!
-  config.cache_classes = true
+  config.cache_classes = false
+  config.action_view.cache_template_loading = true
 
   # Do not eager load code on boot. This avoids loading your whole application
   # just for the purpose of running a single test. If you are using a tool that
@@ -21,6 +25,7 @@ Rails.application.configure do
   # Show full error reports and disable caching.
   config.consider_all_requests_local       = true
   config.action_controller.perform_caching = false
+  config.cache_store = :null_store
 
   # Raise exceptions instead of rendering exception templates.
   config.action_dispatch.show_exceptions = false
@@ -31,6 +36,9 @@ Rails.application.configure do
   # Print deprecation notices to the stderr.
   config.active_support.deprecation = :stderr
 
-  # Raises error for missing translations
-  # config.action_view.raise_on_missing_translations = true
-end
+  # Raise exceptions for disallowed deprecations.
+  config.active_support.disallowed_deprecation = :raise
+
+  # Tell Active Support which deprecation messages to disallow.
+  config.active_support.disallowed_deprecation_warnings = []
+end

+ 0 - 8
frameworks/Ruby/rails/config/initializers/application_controller_renderer.rb

@@ -1,8 +0,0 @@
-# Be sure to restart your server when you modify this file.
-
-# ActiveSupport::Reloader.to_prepare do
-#   ApplicationController.renderer.defaults.merge!(
-#     http_host: 'example.org',
-#     https: false
-#   )
-# end

+ 4 - 3
frameworks/Ruby/rails/config/initializers/backtrace_silencers.rb

@@ -1,7 +1,8 @@
 # Be sure to restart your server when you modify this file.
 
 # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
-# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
+# Rails.backtrace_cleaner.add_silencer { |line| /my_noisy_library/.match?(line) }
 
-# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
-# Rails.backtrace_cleaner.remove_silencers!
+# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code
+# by setting BACKTRACE=1 before calling your invocation, like "BACKTRACE=1 ./bin/rails runner 'MyClass.perform'".
+Rails.backtrace_cleaner.remove_silencers! if ENV["BACKTRACE"]

+ 0 - 25
frameworks/Ruby/rails/config/initializers/content_security_policy.rb

@@ -1,25 +0,0 @@
-# Be sure to restart your server when you modify this file.
-
-# Define an application-wide content security policy
-# For further information see the following documentation
-# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
-
-# Rails.application.config.content_security_policy do |policy|
-#   policy.default_src :self, :https
-#   policy.font_src    :self, :https, :data
-#   policy.img_src     :self, :https, :data
-#   policy.object_src  :none
-#   policy.script_src  :self, :https
-#   policy.style_src   :self, :https
-
-#   # Specify URI for violation reports
-#   # policy.report_uri "/csp-violation-report-endpoint"
-# end
-
-# If you are using UJS then enable automatic nonce generation
-# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
-
-# Report CSP violations to a specified URI
-# For further information see the following documentation:
-# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
-# Rails.application.config.content_security_policy_report_only = true

+ 3 - 1
frameworks/Ruby/rails/config/initializers/filter_parameter_logging.rb

@@ -1,4 +1,6 @@
 # Be sure to restart your server when you modify this file.
 
 # Configure sensitive parameters which will be filtered from the log file.
-Rails.application.config.filter_parameters += [:password]
+Rails.application.config.filter_parameters += [
+    :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
+]

+ 0 - 16
frameworks/Ruby/rails/config/initializers/inflections.rb

@@ -1,16 +0,0 @@
-# Be sure to restart your server when you modify this file.
-
-# Add new inflection rules using the following format. Inflections
-# are locale specific, and you may define rules for as many different
-# locales as you wish. All of these examples are active by default:
-# ActiveSupport::Inflector.inflections(:en) do |inflect|
-#   inflect.plural /^(ox)$/i, '\1en'
-#   inflect.singular /^(ox)en/i, '\1'
-#   inflect.irregular 'person', 'people'
-#   inflect.uncountable %w( fish sheep )
-# end
-
-# These inflection rules are supported but not enabled by default:
-# ActiveSupport::Inflector.inflections(:en) do |inflect|
-#   inflect.acronym 'RESTful'
-# end

+ 0 - 4
frameworks/Ruby/rails/config/initializers/mime_types.rb

@@ -1,4 +0,0 @@
-# Be sure to restart your server when you modify this file.
-
-# Add new mime types for use in respond_to blocks:
-# Mime::Type.register "text/richtext", :rtf

+ 0 - 14
frameworks/Ruby/rails/config/initializers/wrap_parameters.rb

@@ -1,14 +0,0 @@
-# Be sure to restart your server when you modify this file.
-
-# This file contains settings for ActionController::ParamsWrapper which
-# is enabled by default.
-
-# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
-ActiveSupport.on_load(:action_controller) do
-  wrap_parameters format: [:json]
-end
-
-# To enable root element in JSON for ActiveRecord objects.
-# ActiveSupport.on_load(:active_record) do
-#   self.include_root_in_json = true
-# end

+ 0 - 33
frameworks/Ruby/rails/config/locales/en.yml

@@ -1,33 +0,0 @@
-# Files in the config/locales directory are used for internationalization
-# and are automatically loaded by Rails. If you want to use locales other
-# than English, add the necessary files in this directory.
-#
-# To use the locales, use `I18n.t`:
-#
-#     I18n.t 'hello'
-#
-# In views, this is aliased to just `t`:
-#
-#     <%= t('hello') %>
-#
-# To use a different locale, set it with `I18n.locale`:
-#
-#     I18n.locale = :es
-#
-# This would use the information in config/locales/es.yml.
-#
-# The following keys must be escaped otherwise they will not be retrieved by
-# the default I18n backend:
-#
-# true, false, on, off, yes, no
-#
-# Instead, surround them with single quotes.
-#
-# en:
-#   'true': 'foo'
-#
-# To learn more, please read the Rails Internationalization guide
-# available at http://guides.rubyonrails.org/i18n.html.
-
-en:
-  hello: 'Hello world'

+ 0 - 28
frameworks/Ruby/rails/config/mri_puma.rb

@@ -1,28 +0,0 @@
-require_relative 'auto_tune'
-
-# FWBM only... use the puma_auto_tune gem in production!
-num_workers, num_threads = auto_tune
-
-workers num_workers
-threads num_threads, num_threads
-
-preload_app!
-
-# If you are preloading your application and using Active Record, it's
-# recommended that you close any connections to the database before workers
-# are forked to prevent connection leakage.
-#
-before_fork do
-  ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord)
-end
-
-# The code in the `on_worker_boot` will be called if you are using
-# clustered mode by specifying a number of `workers`. After each worker
-# process is booted, this block will be run. If you are using the `preload_app!`
-# option, you will want to use this block to reconnect to any threads
-# or connections that may have been created at application boot, as Ruby
-# cannot share connections between processes.
-#
-on_worker_boot do
-  ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
-end

+ 0 - 158
frameworks/Ruby/rails/config/nginx.conf

@@ -1,158 +0,0 @@
-# This is example contains the bare mininum to get nginx going with
-# Unicorn or Rainbows! servers.  Generally these configuration settings
-# are applicable to other HTTP application servers (and not just Ruby
-# ones), so if you have one working well for proxying another app
-# server, feel free to continue using it.
-#
-# The only setting we feel strongly about is the fail_timeout=0
-# directive in the "upstream" block.  max_fails=0 also has the same
-# effect as fail_timeout=0 for current versions of nginx and may be
-# used in its place.
-#
-# Users are strongly encouraged to refer to nginx documentation for more
-# details and search for other example configs.
-
-# you generally only need one nginx worker unless you're serving
-# large amounts of static files which require blocking disk reads
-worker_processes 8;
-
-# # drop privileges, root is needed on most systems for binding to port 80
-# # (or anything < 1024).  Capability-based security may be available for
-# # your system and worth checking out so you won't need to be root to
-# # start nginx to bind on 80
-# user nobody nogroup; # for systems with a "nogroup"
-#user nobody nobody; # for systems with "nobody" as a group instead
-
-# Feel free to change all paths to suite your needs here, of course
-pid /tmp/nginx.pid;
-#error_log /tmp/nginx.error.log;
-error_log stderr error;
-
-events {
-  worker_connections 4096; # increase if you have lots of clients
-  accept_mutex off; # "on" if nginx worker_processes > 1
-  use epoll; # enable for Linux 2.6+
-  # use kqueue; # enable for FreeBSD, OSX
-}
-
-http {
-  # nginx will find this file in the config directory set at nginx build time
-  include /etc/nginx/mime.types;
-
-  # fallback in case we can't determine a type
-  default_type application/octet-stream;
-
-  # click tracking!
-  #access_log /tmp/nginx.access.log combined;
-  access_log off;
-
-  # you generally want to serve static files with nginx since neither
-  # Unicorn nor Rainbows! is optimized for it at the moment
-  sendfile on;
-
-  tcp_nopush on; # off may be better for *some* Comet/long-poll stuff
-  tcp_nodelay off; # on may be better for some Comet/long-poll stuff
-
-  # we haven't checked to see if Rack::Deflate on the app server is
-  # faster or not than doing compression via nginx.  It's easier
-  # to configure it all in one place here for static files and also
-  # to disable gzip for clients who don't get gzip/deflate right.
-  # There are other gzip settings that may be needed used to deal with
-  # bad clients out there, see http://wiki.nginx.org/NginxHttpGzipModule
-  #gzip on;
-  #gzip_http_version 1.0;
-  #gzip_proxied any;
-  #gzip_min_length 500;
-  #gzip_disable "MSIE [1-6]\.";
-  #gzip_types text/plain text/html text/xml text/css
-  #           text/comma-separated-values
-  #           text/javascript application/x-javascript
-  #           application/atom+xml;
-
-  # this can be any application server, not just Unicorn/Rainbows!
-  upstream app_server {
-    # fail_timeout=0 means we always retry an upstream even if it failed
-    # to return a good HTTP response (in case the Unicorn master nukes a
-    # single worker for timing out).
-
-    # for UNIX domain socket setups:
-    server unix:/tmp/.sock fail_timeout=0;
-
-    # for TCP setups, point these to your backend servers
-    # server 192.168.0.7:8080 fail_timeout=0;
-    # server 192.168.0.8:8080 fail_timeout=0;
-    # server 192.168.0.9:8080 fail_timeout=0;
-  }
-
-  server {
-    # enable one of the following if you're on Linux or FreeBSD
-    listen 8080 default deferred; # for Linux
-    # listen 80 default accept_filter=httpready; # for FreeBSD
-
-    # If you have IPv6, you'll likely want to have two separate listeners.
-    # One on IPv4 only (the default), and another on IPv6 only instead
-    # of a single dual-stack listener.  A dual-stack listener will make
-    # for ugly IPv4 addresses in $remote_addr (e.g ":ffff:10.0.0.1"
-    # instead of just "10.0.0.1") and potentially trigger bugs in
-    # some software.
-    # listen [::]:80 ipv6only=on; # deferred or accept_filter recommended
-
-    client_max_body_size 4G;
-    server_name _;
-
-    # ~2 seconds is often enough for most folks to parse HTML/CSS and
-    # retrieve needed images/icons/frames, connections are cheap in
-    # nginx so increasing this is generally safe...
-    keepalive_timeout 10;
-
-    # path for static files
-    root /path/to/app/current/public;
-
-    # Prefer to serve static files directly from nginx to avoid unnecessary
-    # data copies from the application server.
-    #
-    # try_files directive appeared in in nginx 0.7.27 and has stabilized
-    # over time.  Older versions of nginx (e.g. 0.6.x) requires
-    # "if (!-f $request_filename)" which was less efficient:
-    # http://bogomips.org/unicorn.git/tree/examples/nginx.conf?id=v3.3.1#n127
-    try_files $uri/index.html $uri.html $uri @app;
-
-    location @app {
-      # an HTTP header important enough to have its own Wikipedia entry:
-      #   http://en.wikipedia.org/wiki/X-Forwarded-For
-      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
-
-      # enable this if you forward HTTPS traffic to unicorn,
-      # this helps Rack set the proper URL scheme for doing redirects:
-      # proxy_set_header X-Forwarded-Proto $scheme;
-
-      # pass the Host: header from the client right along so redirects
-      # can be set properly within the Rack application
-      proxy_set_header Host $http_host;
-
-      # we don't want nginx trying to do something clever with
-      # redirects, we set the Host: header above already.
-      proxy_redirect off;
-
-      # set "proxy_buffering off" *only* for Rainbows! when doing
-      # Comet/long-poll/streaming.  It's also safe to set if you're using
-      # only serving fast clients with Unicorn + nginx, but not slow
-      # clients.  You normally want nginx to buffer responses to slow
-      # clients, even with Rails 3.1 streaming because otherwise a slow
-      # client can become a bottleneck of Unicorn.
-      #
-      # The Rack application may also set "X-Accel-Buffering (yes|no)"
-      # in the response headers do disable/enable buffering on a
-      # per-response basis.
-      # proxy_buffering off;
-
-      proxy_pass http://app_server;
-    }
-
-    # Rails error pages
-    error_page 500 502 503 504 /500.html;
-    location = /500.html {
-      root /path/to/app/current/public;
-    }
-  }
-}

+ 49 - 0
frameworks/Ruby/rails/config/puma.rb

@@ -0,0 +1,49 @@
+require_relative 'auto_tune'
+
+# FWBM only... use the puma_auto_tune gem in production!
+tuned_num_workers, tuned_num_threads = auto_tune
+
+# Puma can serve each request in a thread from an internal thread pool.
+# The `threads` method setting takes two numbers: a minimum and maximum.
+# Any libraries that use thread pools should be configured to match
+# the maximum value specified for Puma. Default is set to 5 threads for minimum
+# and maximum; this matches the default thread size of Active Record.
+#
+max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
+min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
+threads min_threads_count, max_threads_count
+
+# Specifies the `worker_timeout` threshold that Puma will use to wait before
+# terminating a worker in development environments.
+#
+worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
+
+# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
+#
+port ENV.fetch("PORT") { 3000 }
+
+# Specifies the `environment` that Puma will run in.
+#
+environment ENV.fetch("RAILS_ENV") { "development" }
+
+# Specifies the `pidfile` that Puma will use.
+pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
+
+# Specifies the number of `workers` to boot in clustered mode.
+# Workers are forked web server processes. If using threads and workers together
+# the concurrency of the application would be max `threads` * `workers`.
+# Workers do not work on JRuby or Windows (both of which do not support
+# processes).
+#
+# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
+workers tuned_num_workers
+
+# Use the `preload_app!` method when specifying a `workers` number.
+# This directive tells Puma to first boot the application and load code
+# before forking the application. This takes advantage of Copy On Write
+# process behavior so workers use less memory.
+#
+preload_app!
+
+# Allow puma to be restarted by `rails restart` command.
+plugin :tmp_restart

+ 1 - 0
frameworks/Ruby/rails/config/routes.rb

@@ -7,4 +7,5 @@ Rails.application.routes.draw do
   get "fortunes", to: "hello_world#fortune"
   get "updates", to: "hello_world#update"
   get "plaintext", to: "hello_world#plaintext"
+  get "cached", to: "hello_world#cached_query"
 end

+ 0 - 59
frameworks/Ruby/rails/config/unicorn.rb

@@ -1,59 +0,0 @@
-require_relative 'auto_tune'
-
-# FWBM only...
-num_workers, = auto_tune
-worker_processes num_workers
-
-listen "/tmp/.sock", :backlog => 512
-
-preload_app true
-
-GC.respond_to?(:copy_on_write_friendly=) and
-  GC.copy_on_write_friendly = true
-
-before_fork do |server, worker|
-  # the following is highly recomended for Rails + "preload_app true"
-  # as there's no need for the master process to hold a connection
-  defined?(ActiveRecord::Base) and
-    ActiveRecord::Base.connection.disconnect!
-
-  # The following is only recommended for memory/DB-constrained
-  # installations.  It is not needed if your system can house
-  # twice as many worker_processes as you have configured.
-  #
-  # # This allows a new master process to incrementally
-  # # phase out the old master process with SIGTTOU to avoid a
-  # # thundering herd (especially in the "preload_app false" case)
-  # # when doing a transparent upgrade.  The last worker spawned
-  # # will then kill off the old master process with a SIGQUIT.
-  # old_pid = "#{server.config[:pid]}.oldbin"
-  # if old_pid != server.pid
-  #   begin
-  #     sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
-  #     Process.kill(sig, File.read(old_pid).to_i)
-  #   rescue Errno::ENOENT, Errno::ESRCH
-  #   end
-  # end
-  #
-  # Throttle the master from forking too quickly by sleeping.  Due
-  # to the implementation of standard Unix signal handlers, this
-  # helps (but does not completely) prevent identical, repeated signals
-  # from being lost when the receiving process is busy.
-  # sleep 1
-end
-
-after_fork do |server, worker|
-  # per-process listener ports for debugging/admin/migrations
-  # addr = "127.0.0.1:#{9293 + worker.nr}"
-  # server.listen(addr, :tries => -1, :delay => 5, :tcp_nopush => true)
-
-  # the following is *required* for Rails + "preload_app true",
-  defined?(ActiveRecord::Base) and
-    ActiveRecord::Base.establish_connection
-
-  # if preload_app is true, then you may also want to check and
-  # restart any other shared sockets/descriptors such as Memcached,
-  # and Redis.  TokyoCabinet file handles are safe to reuse
-  # between any number of forked children (assuming your kernel
-  # correctly implements pread()/pwrite() system calls)
-end

+ 16 - 0
frameworks/Ruby/rails/rails-mysql.dockerfile

@@ -0,0 +1,16 @@
+FROM ruby:3.0
+
+ENV BUNDLE_WITHOUT=postgresql
+ENV RAILS_ENV=production_mysql
+ENV PORT=8080
+
+EXPOSE 8080
+WORKDIR /rails
+
+COPY ./Gemfile* /rails/
+
+RUN bundle install --jobs=8
+
+COPY . /rails/
+
+CMD ["rails", "server"]

+ 0 - 13
frameworks/Ruby/rails/rails-postgresql.dockerfile

@@ -1,13 +0,0 @@
-FROM ruby:2.6
-
-ADD ./ /rails
-
-WORKDIR /rails
-
-RUN bundle install --jobs=4 --gemfile=/rails/Gemfile --path=/rails/rails/bundle --without mysql
-
-ENV DBTYPE=postgresql
-
-EXPOSE 8080
-
-CMD DB_HOST=tfb-database bundle exec puma -C config/mri_puma.rb -b tcp://0.0.0.0:8080 -e production_postgresql

+ 0 - 14
frameworks/Ruby/rails/rails-unicorn.dockerfile

@@ -1,14 +0,0 @@
-FROM ruby:2.6
-
-RUN apt-get update -yqq && apt-get install -yqq nginx
-
-ADD ./ /rails
-
-WORKDIR /rails
-
-RUN bundle install --jobs=4 --gemfile=/rails/Gemfile --path=/rails/rails/bundle --without=postgresql
-
-EXPOSE 8080
-
-CMD nginx -c /rails/config/nginx.conf && \
-  DB_HOST=tfb-database bundle exec unicorn_rails -E production_mysql -c config/unicorn.rb

+ 11 - 4
frameworks/Ruby/rails/rails.dockerfile

@@ -1,9 +1,16 @@
-FROM ruby:2.6
+FROM ruby:3.0
 
-ADD ./ /rails
+ENV BUNDLE_WITHOUT=mysql
+ENV RAILS_ENV=production_postgresql
+ENV PORT=8080
 
+EXPOSE 8080
 WORKDIR /rails
 
-RUN bundle install --jobs=4 --gemfile=/rails/Gemfile --path=/rails/rails/bundle --without postgresql
+COPY ./Gemfile* /rails/
 
-CMD DB_HOST=tfb-database bundle exec puma -C config/mri_puma.rb -b tcp://0.0.0.0:8080 -e production_mysql
+RUN bundle install --jobs=8
+
+COPY . /rails/
+
+CMD ["rails", "server"]