Skip to content

Commit 1bf0a22

Browse files
authored
[ruby/rack] Add Pitchfork server (#9733)
Pitchfork is a preforking HTTP server based on Unicorn (which hasn't seen an update since 2021).
1 parent 889cb52 commit 1bf0a22

File tree

8 files changed

+64
-0
lines changed

8 files changed

+64
-0
lines changed

frameworks/Ruby/rack/Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ group :iodine, optional: true do
2222
gem 'iodine', '~> 0.7', platforms: %i[ruby mswin]
2323
end
2424

25+
group :pitchfork, optional: true do
26+
gem 'pitchfork', '~> 0.17'
27+
end
28+
2529
group :puma, optional: true do
2630
gem 'puma', '~> 6.5'
2731
end

frameworks/Ruby/rack/Gemfile.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ GEM
6565
language_server-protocol (3.17.0.4)
6666
lint_roller (1.1.0)
6767
localhost (1.3.1)
68+
logger (1.6.6)
6869
mapping (1.1.1)
6970
memory-leak (0.5.2)
7071
metrics (0.12.2)
@@ -75,6 +76,9 @@ GEM
7576
ast (~> 2.4.1)
7677
racc
7778
pg (1.5.9)
79+
pitchfork (0.17.0)
80+
logger
81+
rack (>= 2.0)
7882
protocol-hpack (1.5.1)
7983
protocol-http (0.49.0)
8084
protocol-http1 (0.30.0)
@@ -139,6 +143,7 @@ DEPENDENCIES
139143
jdbc-postgres (~> 42.2)
140144
json (~> 2.10)
141145
pg (~> 1.5)
146+
pitchfork (~> 0.17)
142147
puma (~> 6.5)
143148
rack (~> 3.0)
144149
rack-test

frameworks/Ruby/rack/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ The tests were run with:
1818
* [Puma 6.4](http://puma.io/)
1919
* [Iodine](https://github.com/boazsegev/iodine)
2020
* [Falcon](https://github.com/socketry/falcon)
21+
* [Pitchfork](https://github.com/Shopify/pitchfork)
2122
* [Sequel 5](https://sequel.jeremyevans.net/)
2223

2324

frameworks/Ruby/rack/benchmark_config.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,27 @@
106106
"database_os": "Linux",
107107
"display_name": "rack-puma-jruby-sequel-raw",
108108
"notes": ""
109+
},
110+
"pitchfork": {
111+
"json_url": "/json",
112+
"plaintext_url": "/plaintext",
113+
"db_url": "/db",
114+
"query_url": "/queries?queries=",
115+
"fortune_url": "/fortunes",
116+
"update_url": "/updates?queries=",
117+
"port": 8080,
118+
"approach": "Realistic",
119+
"classification": "Platform",
120+
"orm": "raw",
121+
"database": "Postgres",
122+
"framework": "rack",
123+
"language": "Ruby",
124+
"platform": "Mri",
125+
"webserver": "Pitchfork",
126+
"os": "Linux",
127+
"database_os": "Linux",
128+
"display_name": "rack-pitchfork-mri-sequel-raw",
129+
"notes": ""
109130
}
110131
}
111132
]

frameworks/Ruby/rack/config/auto_tune.rb

100755100644
File mode changed.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# frozen_string_literal: true
2+
3+
require_relative 'auto_tune'
4+
require 'sequel'
5+
num_workers, = auto_tune
6+
7+
worker_processes num_workers
8+
9+
before_fork do |_server|
10+
Sequel::DATABASES.each(&:disconnect)
11+
end

frameworks/Ruby/rack/falcon.rb

100755100644
File mode changed.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM ruby:3.4
2+
3+
ENV RUBY_YJIT_ENABLE=1
4+
5+
# Use Jemalloc
6+
RUN apt-get update && \
7+
apt-get install -y --no-install-recommends libjemalloc2
8+
ENV LD_PRELOAD=libjemalloc.so.2
9+
10+
WORKDIR /rack
11+
12+
COPY Gemfile ./
13+
14+
ENV BUNDLE_FORCE_RUBY_PLATFORM=true
15+
RUN bundle config set with 'pitchfork'
16+
RUN bundle install --jobs=8
17+
18+
COPY . .
19+
20+
EXPOSE 8080
21+
22+
CMD bundle exec pitchfork -c config/pitchfork.rb -o 0.0.0.0 -p 8080 -E production

0 commit comments

Comments
 (0)