Преглед изворни кода

[ruby/rack] Add Passenger server (#9762)

Passenger has been removed from most framework tests.
This adds it to Rack, so we at least test it once.
Petrik de Heus пре 5 месеци
родитељ
комит
1d584f8e39

+ 5 - 0
frameworks/Ruby/rack/Gemfile

@@ -22,6 +22,11 @@ group :iodine, optional: true do
   gem 'iodine', '~> 0.7', platforms: %i[ruby mswin]
 end
 
+group :passenger, optional: true do
+  gem 'base64' # required by passenger on Ruby 3.4
+  gem 'passenger', '~> 6.0', platforms: [:ruby, :mswin], require: false
+end
+
 group :pitchfork, optional: true do
   gem 'pitchfork', '~> 0.17'
 end

+ 10 - 0
frameworks/Ruby/rack/Gemfile.lock

@@ -32,6 +32,7 @@ GEM
     async-service (0.13.0)
       async
       async-container (~> 0.16)
+    base64 (0.2.0)
     bigdecimal (3.1.9)
     concurrent-ruby (1.3.5)
     connection_pool (2.5.0)
@@ -75,6 +76,10 @@ GEM
     parser (3.3.7.1)
       ast (~> 2.4.1)
       racc
+    passenger (6.0.26)
+      rack (>= 1.6.13)
+      rackup (>= 2.0.0)
+      rake (>= 12.3.3)
     pg (1.5.9)
     pitchfork (0.17.0)
       logger
@@ -95,8 +100,11 @@ GEM
     rack (3.1.11)
     rack-test (2.2.0)
       rack (>= 1.3)
+    rackup (2.2.1)
+      rack (>= 3)
     rainbow (3.1.1)
     raindrops (0.20.1)
+    rake (13.2.1)
     regexp_parser (2.10.0)
     rubocop (1.73.2)
       json (~> 2.3)
@@ -137,11 +145,13 @@ PLATFORMS
   x86_64-linux
 
 DEPENDENCIES
+  base64
   connection_pool (~> 2.4)
   falcon (~> 0.47)
   iodine (~> 0.7)
   jdbc-postgres (~> 42.2)
   json (~> 2.10)
+  passenger (~> 6.0)
   pg (~> 1.5)
   pitchfork (~> 0.17)
   puma (~> 6.5)

+ 21 - 0
frameworks/Ruby/rack/benchmark_config.json

@@ -107,6 +107,27 @@
         "display_name": "rack-puma-jruby-sequel-raw",
         "notes": ""
       },
+      "passenger": {
+        "json_url": "/json",
+        "plaintext_url": "/plaintext",
+        "db_url": "/db",
+        "query_url": "/queries?queries=",
+        "fortune_url": "/fortunes",
+        "update_url": "/updates?queries=",
+        "port": 8080,
+        "approach": "Realistic",
+        "classification": "Micro",
+        "orm": "raw",
+        "database": "Postgres",
+        "framework": "rack",
+        "language": "Ruby",
+        "platform": "Jruby",
+        "webserver": "Passenger",
+        "os": "Linux",
+        "database_os": "Linux",
+        "display_name": "rack-passenger-mri-sequel-raw",
+        "notes": ""
+      },
       "pitchfork": {
         "json_url": "/json",
         "plaintext_url": "/plaintext",

+ 1 - 11
frameworks/Ruby/rack/hello_world.rb

@@ -25,17 +25,7 @@ class HelloWorld
   PLAINTEXT_TYPE = 'text/plain'
   DATE = 'Date'
   SERVER = 'Server'
-  SERVER_STRING = if defined?(Puma)
-                    'Puma'
-                  elsif defined?(Iodine)
-                    'Iodine'
-                  elsif defined?(Unicorn)
-                    'Unicorn'
-                  elsif defined?(Falcon)
-                    'Falcon'
-                  else
-                    'Ruby Rack'
-                  end
+  SERVER_STRING = 'Rack'
   TEMPLATE_PREFIX = '<!DOCTYPE html>
 <html>
 <head>

+ 31 - 0
frameworks/Ruby/rack/rack-passenger.dockerfile

@@ -0,0 +1,31 @@
+FROM ruby:3.4
+
+ENV RUBY_YJIT_ENABLE=1
+
+# Use Jemalloc
+RUN apt-get update && \
+    apt-get install -y --no-install-recommends libjemalloc2
+ENV LD_PRELOAD=libjemalloc.so.2
+
+WORKDIR /rack
+
+COPY Gemfile ./
+
+ENV BUNDLE_FORCE_RUBY_PLATFORM=true
+RUN bundle config set with 'passenger'
+RUN bundle install --jobs=8
+
+COPY . .
+
+# TODO: https://github.com/phusion/passenger/issues/1916
+ENV _PASSENGER_FORCE_HTTP_SESSION=true
+
+RUN ruby config/auto_tune.rb | grep -Eo '[0-9]+' | head -n 1 > instances
+
+EXPOSE 8080
+
+CMD bundle exec passenger start --log-level 1 \
+       --engine builtin --disable-turbocaching --disable-security-update-check \
+       --spawn-method direct --max-pool-size $(cat instances) --min-instances $(cat instances) --max-request-queue-size 1024 \
+       --address 0.0.0.0 --port 8080 --environment production
+