Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ruby/sinatra] Add agoo server #9468

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions frameworks/Ruby/sinatra-sequel/boot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@

SERVER_STRING =
if defined?(PhusionPassenger)
[
PhusionPassenger::SharedConstants::SERVER_TOKEN_NAME,
PhusionPassenger::VERSION_STRING
].join('/').freeze
'passenger'
elsif defined?(Puma)
Puma::Const::PUMA_SERVER_STRING
'puma'
elsif defined?(Unicorn)
Unicorn::HttpParser::DEFAULTS['SERVER_SOFTWARE']
'unicorn'
elsif defined?(Agoo)
'agoo'
end

Bundler.require(:default) # Load core modules
Expand Down
13 changes: 9 additions & 4 deletions frameworks/Ruby/sinatra/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,27 @@ gem 'activerecord', '~> 7.2', require: 'active_record'
gem 'json', '~> 2.8'
gem 'sinatra', '~> 4.0', require: 'sinatra/base'

group :mysql do
group :mysql, optional: true do
gem 'mysql2', '~> 0.5', :platforms=>[:ruby, :mswin]
end

group :postgresql do
group :postgresql, optional: true do
gem 'pg', '~> 1.5', platforms: [:ruby, :mswin]
end

group :passenger do
group :passenger, optional: true do
gem 'passenger', '~> 6.0', platforms: [:ruby, :mswin], require: false
end

group :puma do
group :puma, optional: true do
gem 'puma', '~> 6.4', require: false
end

group :unicorn do
gem 'unicorn', '~> 6.1', platforms: [:ruby, :mswin], require: false
end

group :agoo, optional: true do
gem 'agoo', require: false
gem 'rackup'
end
3 changes: 3 additions & 0 deletions frameworks/Ruby/sinatra/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ GEM
minitest (>= 5.1)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
agoo (2.15.13)
base64 (0.2.0)
bigdecimal (3.1.8)
concurrent-ruby (1.3.4)
Expand Down Expand Up @@ -74,11 +75,13 @@ PLATFORMS

DEPENDENCIES
activerecord (~> 7.2)
agoo
json (~> 2.8)
mysql2 (~> 0.5)
passenger (~> 6.0)
pg (~> 1.5)
puma (~> 6.4)
rackup
sinatra (~> 4.0)
unicorn (~> 6.1)

Expand Down
22 changes: 22 additions & 0 deletions frameworks/Ruby/sinatra/benchmark_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,28 @@
"versus": "rack-postgres-puma-mri",
"notes": ""
},
"postgres-agoo-mri": {
"json_url": "/json",
"db_url": "/db",
"query_url": "/queries?queries=",
"fortune_url": "/fortunes",
"update_url": "/updates?queries=",
"plaintext_url": "/plaintext",
"port": 8080,
"approach": "Realistic",
"classification": "Micro",
"database": "Postgres",
"framework": "sinatra",
"language": "Ruby",
"orm": "Full",
"platform": "Rack",
"webserver": "Agoo",
"os": "Linux",
"database_os": "Linux",
"display_name": "sinatra-postgres-agoo-mri",
"versus": "rack-postgres-agoo-mri",
"notes": ""
},
"postgres-passenger-mri": {
"db_url": "/db",
"query_url": "/queries?queries=",
Expand Down
11 changes: 5 additions & 6 deletions frameworks/Ruby/sinatra/boot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@

SERVER_STRING =
if defined?(PhusionPassenger)
[
PhusionPassenger::SharedConstants::SERVER_TOKEN_NAME,
PhusionPassenger::VERSION_STRING
].join('/').freeze
'passenger'
elsif defined?(Puma)
Puma::Const::PUMA_SERVER_STRING
'puma'
elsif defined?(Unicorn)
Unicorn::HttpParser::DEFAULTS['SERVER_SOFTWARE']
'unicorn'
elsif defined?(Agoo)
'agoo'
end

Bundler.require(:default) # Load core modules
Expand Down
20 changes: 20 additions & 0 deletions frameworks/Ruby/sinatra/sinatra-postgres-agoo-mri.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM ruby:3.4-rc

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

ADD ./ /sinatra
WORKDIR /sinatra

ENV BUNDLE_WITH=postgresql:agoo
RUN bundle install --jobs=4 --gemfile=/sinatra/Gemfile

ENV DBTYPE=postgresql

EXPOSE 8080

CMD RACK_ENV=production bundle exec rackup -r agoo -s agoo -p 8080 -q -O workers=$(ruby config/auto_tune.rb | grep -Eo '[0-9]+' | head -n 1)
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ENV LD_PRELOAD=libjemalloc.so.2
ADD ./ /sinatra
WORKDIR /sinatra

ENV BUNDLE_WITHOUT=mysql:puma:unicorn
ENV BUNDLE_WITH=postgresql:passenger
RUN bundle install --jobs=4 --gemfile=/sinatra/Gemfile

# TODO: https://github.com/phusion/passenger/issues/1916
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ENV LD_PRELOAD=libjemalloc.so.2
ADD ./ /sinatra
WORKDIR /sinatra

ENV BUNDLE_WITHOUT=mysql:passenger:puma
ENV BUNDLE_WITH=postgresql:unicorn
RUN bundle install --jobs=4 --gemfile=/sinatra/Gemfile

ENV DBTYPE=postgresql
Expand Down
2 changes: 1 addition & 1 deletion frameworks/Ruby/sinatra/sinatra-postgres.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ENV LD_PRELOAD=libjemalloc.so.2
ADD ./ /sinatra
WORKDIR /sinatra

ENV BUNDLE_WITHOUT=mysql:passenger:unicorn
ENV BUNDLE_WITH=postgresql:puma
RUN bundle install --jobs=4 --gemfile=/sinatra/Gemfile

ENV DBTYPE=postgresql
Expand Down
2 changes: 1 addition & 1 deletion frameworks/Ruby/sinatra/sinatra.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ENV LD_PRELOAD=libjemalloc.so.2
ADD ./ /sinatra
WORKDIR /sinatra

ENV BUNDLE_WITHOUT=postgresql:passenger:unicorn
ENV BUNDLE_WITH=mysql:puma
RUN bundle install --jobs=4 --gemfile=/sinatra/Gemfile

ENV DBTYPE=mysql
Expand Down
Loading