Browse Source

Merge pull request #9492 from p8/roda-sequel/iodine

[ruby/roda] Add Iodine server
Mike Smith 7 months ago
parent
commit
7ce9e81bcc

+ 12 - 3
frameworks/Ruby/roda-sequel/Gemfile

@@ -3,12 +3,9 @@ source "https://rubygems.org"
 gem 'base64' # required by passenger on Ruby 3.4
 gem 'base64' # required by passenger on Ruby 3.4
 gem "erubi", "~> 1.12"
 gem "erubi", "~> 1.12"
 gem "json", "~> 2.8"
 gem "json", "~> 2.8"
-gem "passenger", "~> 6.0", platforms: %i[ruby mswin], require: false
-gem "puma", "~> 6.2", require: false
 gem "sequel", "~> 5.67"
 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 "unicorn", "~> 6.1", platforms: %i[ruby mswin], require: false
 
 
 group :mysql do
 group :mysql do
   gem "mysql2", "~> 0.5", platforms: %i[ruby mswin]
   gem "mysql2", "~> 0.5", platforms: %i[ruby mswin]
@@ -18,3 +15,15 @@ group :postgresql do
   gem "pg", "~> 1.4", platforms: %i[ruby mswin]
   gem "pg", "~> 1.4", platforms: %i[ruby mswin]
   gem "sequel_pg", "~> 1.17", platforms: :ruby, require: false
   gem "sequel_pg", "~> 1.17", platforms: :ruby, require: false
 end
 end
+
+group :iodine, optional: true do
+  gem "iodine", "~> 0.7", require: false
+end
+
+group :puma, optional: true do
+  gem "puma", "~> 6.2", require: false
+end
+
+group :unicorn, optional: true do
+  gem "unicorn", "~> 6.1", platforms: %i[ruby mswin], require: false
+end

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

@@ -8,19 +8,11 @@ GEM
     kgio (2.11.4)
     kgio (2.11.4)
     mysql2 (0.5.6)
     mysql2 (0.5.6)
     nio4r (2.7.4)
     nio4r (2.7.4)
-    passenger (6.0.23)
-      rack (>= 1.6.13)
-      rackup
-      rake (>= 12.3.3)
     pg (1.5.8)
     pg (1.5.8)
     puma (6.5.0)
     puma (6.5.0)
       nio4r (~> 2.0)
       nio4r (~> 2.0)
     rack (3.1.8)
     rack (3.1.8)
-    rackup (2.1.0)
-      rack (>= 3)
-      webrick (~> 1.8)
     raindrops (0.20.1)
     raindrops (0.20.1)
-    rake (13.2.1)
     roda (3.85.0)
     roda (3.85.0)
       rack
       rack
     sequel (5.85.0)
     sequel (5.85.0)
@@ -32,7 +24,6 @@ GEM
     unicorn (6.1.0)
     unicorn (6.1.0)
       kgio (~> 2.6)
       kgio (~> 2.6)
       raindrops (~> 0.7)
       raindrops (~> 0.7)
-    webrick (1.8.2)
 
 
 PLATFORMS
 PLATFORMS
   ruby
   ruby
@@ -43,7 +34,6 @@ DEPENDENCIES
   erubi (~> 1.12)
   erubi (~> 1.12)
   json (~> 2.8)
   json (~> 2.8)
   mysql2 (~> 0.5)
   mysql2 (~> 0.5)
-  passenger (~> 6.0)
   pg (~> 1.4)
   pg (~> 1.4)
   puma (~> 6.2)
   puma (~> 6.2)
   roda (~> 3.66)
   roda (~> 3.66)

+ 3 - 3
frameworks/Ruby/roda-sequel/README.md

@@ -12,10 +12,10 @@ comparing a variety of web platforms.
 
 
 The tests will be run with:
 The tests will be run with:
 
 
-* [Ruby 3.3](http://www.ruby-lang.org)
+* [Ruby 3.4](http://www.ruby-lang.org)
 * [Puma 6](http://puma.io)
 * [Puma 6](http://puma.io)
-* [Passenger 6](https://www.phusionpassenger.com)
-* [Unicorn 5](https://bogomips.org/unicorn/)
+* [Unicorn 6](https://bogomips.org/unicorn/)
+* [Iodine](https://github.com/boazsegev/iodine)
 * [Roda 3](http://roda.jeremyevans.net)
 * [Roda 3](http://roda.jeremyevans.net)
 * [Sequel 5](http://sequel.jeremyevans.net)
 * [Sequel 5](http://sequel.jeremyevans.net)
 * [Erubi 1](https://github.com/jeremyevans/erubi)
 * [Erubi 1](https://github.com/jeremyevans/erubi)

+ 6 - 4
frameworks/Ruby/roda-sequel/benchmark_config.json

@@ -44,11 +44,13 @@
         "versus": "rack-sequel-postgres-puma-mri",
         "versus": "rack-sequel-postgres-puma-mri",
         "notes": ""
         "notes": ""
       },
       },
-      "postgres-passenger-mri": {
+      "postgres-iodine-mri": {
+        "json_url": "/json",
         "db_url": "/db",
         "db_url": "/db",
         "query_url": "/queries?queries=",
         "query_url": "/queries?queries=",
         "fortune_url": "/fortunes",
         "fortune_url": "/fortunes",
         "update_url": "/updates?queries=",
         "update_url": "/updates?queries=",
+        "plaintext_url": "/plaintext",
         "port": 8080,
         "port": 8080,
         "approach": "Realistic",
         "approach": "Realistic",
         "classification": "Micro",
         "classification": "Micro",
@@ -57,11 +59,11 @@
         "language": "Ruby",
         "language": "Ruby",
         "orm": "Full",
         "orm": "Full",
         "platform": "Rack",
         "platform": "Rack",
-        "webserver": "Passenger",
+        "webserver": "Iodine",
         "os": "Linux",
         "os": "Linux",
         "database_os": "Linux",
         "database_os": "Linux",
-        "display_name": "roda-sequel-postgres-passenger-mri",
-        "versus": "rack-sequel-postgres-passenger-mri",
+        "display_name": "roda-sequel-postgres-iodine-mri",
+        "versus": "rack-sequel-postgres-iodine-mri",
         "notes": ""
         "notes": ""
       },
       },
       "postgres-unicorn-mri": {
       "postgres-unicorn-mri": {

+ 5 - 8
frameworks/Ruby/roda-sequel/boot.rb

@@ -9,15 +9,12 @@ QUERIES_MAX = 500
 SEQUEL_NO_ASSOCIATIONS = true
 SEQUEL_NO_ASSOCIATIONS = true
 
 
 SERVER_STRING =
 SERVER_STRING =
-  if defined?(PhusionPassenger)
-    [
-      PhusionPassenger::SharedConstants::SERVER_TOKEN_NAME,
-      PhusionPassenger::VERSION_STRING
-    ].join("/").freeze
+  if defined?(Iodine)
+    "Iodine"
   elsif defined?(Puma)
   elsif defined?(Puma)
-    Puma::Const::PUMA_SERVER_STRING
+    "Puma"
   elsif defined?(Unicorn)
   elsif defined?(Unicorn)
-    Unicorn::HttpParser::DEFAULTS["SERVER_SOFTWARE"]
+    "Unicorn"
   end
   end
 
 
 Bundler.require(:default) # Load core modules
 Bundler.require(:default) # Load core modules
@@ -48,7 +45,7 @@ def connect(dbtype)
         (threads = Puma.cli_config.options.fetch(:max_threads)) > 1
         (threads = Puma.cli_config.options.fetch(:max_threads)) > 1
     opts[:max_connections] = (2 * Math.log(threads)).floor
     opts[:max_connections] = (2 * Math.log(threads)).floor
     opts[:pool_timeout] = 10
     opts[:pool_timeout] = 10
-  else
+  elsif defined?(Unicorn)
     Sequel.single_threaded = true
     Sequel.single_threaded = true
   end
   end
 
 

+ 21 - 0
frameworks/Ruby/roda-sequel/roda-sequel-postgres-iodine-mri.dockerfile

@@ -0,0 +1,21 @@
+FROM ruby:3.4
+
+ADD ./ /roda-sequel
+WORKDIR /roda-sequel
+
+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
+
+ENV BUNDLE_FORCE_RUBY_PLATFORM=true
+RUN bundle config set with 'iodine'
+RUN bundle install --jobs=8
+
+ENV DBTYPE=postgresql
+
+EXPOSE 8080
+
+CMD bundle exec iodine -p 8080

+ 0 - 27
frameworks/Ruby/roda-sequel/roda-sequel-postgres-passenger-mri.dockerfile

@@ -1,27 +0,0 @@
-FROM ruby:3.4-rc
-
-ADD ./ /roda-sequel
-WORKDIR /roda-sequel
-
-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
-
-ENV BUNDLE_FORCE_RUBY_PLATFORM=true
-RUN bundle install --jobs=8
-
-# TODO: https://github.com/phusion/passenger/issues/1916
-ENV _PASSENGER_FORCE_HTTP_SESSION=true
-ENV DBTYPE=postgresql
-
-RUN ruby -r /roda-sequel/config/auto_tune -e 'puts auto_tune.first' > 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

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

@@ -11,6 +11,7 @@ RUN apt-get update && \
 ENV LD_PRELOAD=libjemalloc.so.2
 ENV LD_PRELOAD=libjemalloc.so.2
 
 
 ENV BUNDLE_FORCE_RUBY_PLATFORM=true
 ENV BUNDLE_FORCE_RUBY_PLATFORM=true
+RUN bundle config set with 'unicorn'
 RUN bundle install --jobs=8
 RUN bundle install --jobs=8
 
 
 ENV DBTYPE=postgresql
 ENV DBTYPE=postgresql

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

@@ -11,6 +11,7 @@ RUN apt-get update && \
 ENV LD_PRELOAD=libjemalloc.so.2
 ENV LD_PRELOAD=libjemalloc.so.2
 
 
 ENV BUNDLE_FORCE_RUBY_PLATFORM=true
 ENV BUNDLE_FORCE_RUBY_PLATFORM=true
+RUN bundle config set with 'puma'
 RUN bundle install --jobs=8
 RUN bundle install --jobs=8
 
 
 ENV DBTYPE=postgresql
 ENV DBTYPE=postgresql

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

@@ -11,6 +11,7 @@ RUN apt-get update && \
 ENV LD_PRELOAD=libjemalloc.so.2
 ENV LD_PRELOAD=libjemalloc.so.2
 
 
 ENV BUNDLE_FORCE_RUBY_PLATFORM=true
 ENV BUNDLE_FORCE_RUBY_PLATFORM=true
+RUN bundle config set with 'puma'
 RUN bundle install --jobs=8
 RUN bundle install --jobs=8
 
 
 ENV DBTYPE=mysql
 ENV DBTYPE=mysql