Skip to content

Commit

Permalink
Revert "Switch from WEBrick to Puma"
Browse files Browse the repository at this point in the history
  • Loading branch information
tschafer-gc authored Nov 19, 2024
1 parent 2487508 commit 940382a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 33 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ jobs:
fail-fast: false
matrix:
ruby_version: ["3.0", "3.1", "3.2", "3.3"]
rack_version: ["2.2.5", "3.1"]
runs-on: ubuntu-latest
services:
postgres:
Expand All @@ -46,14 +45,13 @@ jobs:
PGPASSWORD: password
PGHOST: localhost
BUNDLE_RUBYGEMS__PKG__GITHUB__COM: gocardless-robot-readonly:${{ secrets.GITHUB_TOKEN }}
RACK_VERSION: "${{ matrix.rack_version }}"
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: "${{ matrix.ruby_version }}"
ruby-version: "${{ matrix.ruby-version }}"
- name: Start bin/que
run: |
bundle exec bin/que ./lib/que.rb --metrics-port=8080 --ci
Expand Down
8 changes: 0 additions & 8 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ group :development, :test do
gem 'rubocop-rspec', '~> 3.0.2'
gem 'rubocop-sequel', '~> 0.3.4'
gem 'sequel', require: nil

rack_version = ENV.fetch('RACK_VERSION', "3.1")
gem "rack", rack_version
if Gem::Version.new(rack_version) < Gem::Version.new('3.0.0')
gem "rackup", "~> 1.0"
else
gem "rackup", "~> 2.0"
end
end

group :test do
Expand Down
46 changes: 25 additions & 21 deletions bin/que
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
require "logger"
require "optparse"
require "ostruct"
require "prometheus/middleware/exporter"
require "prometheus_gcstat"
require "puma"
require "que"
require "rack"
USE_RACKUP = Rack.release.split(".")[0].to_i >= 3
if USE_RACKUP
require "prometheus/middleware/exporter"
require "prometheus_gcstat"
require "webrick"

if Rack.release[0] == "3"
# Required if using Rack 3.x
require "rackup"
end
require "rack/handler/puma"

$stdout.sync = true

Expand Down Expand Up @@ -176,21 +176,25 @@ if options.metrics_port
)

host = "0.0.0.0"

handler =
if USE_RACKUP
Rackup::Handler::Puma
else
Rack::Handler::Puma
end

handler.run(
app,
Host: host,
Port: options.metrics_port,
Silent: false,
AccessLog: [],
)
logger = WEBrick::Log.new("/dev/null")

if Rack.release[0] == "3"
Rackup::Handler::WEBrick.run(
app,
Host: host,
Port: options.metrics_port,
Logger: logger,
AccessLog: [],
)
else
Rack::Handler::WEBrick.run(
app,
Host: host,
Port: options.metrics_port,
Logger: logger,
AccessLog: [],
)
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion que.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ Gem::Specification.new do |spec|
# This is highly non ideal, but unless we properly fork, we have to do this for now.
spec.add_dependency "prometheus-client"

spec.add_dependency "puma"
spec.add_dependency "rack", ">= 2", "< 4"
spec.add_dependency "rackup"
spec.add_dependency "webrick"

spec.add_runtime_dependency "activesupport"
spec.metadata["rubygems_mfa_required"] = "true"
Expand Down

0 comments on commit 940382a

Please sign in to comment.