Skip to content

Commit

Permalink
Fix recursive prune_bundler
Browse files Browse the repository at this point in the history
Resolve puma#2319
  • Loading branch information
AlexWayfer committed Jul 27, 2020
1 parent df57cec commit 39f9c72
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 0 deletions.
1 change: 1 addition & 0 deletions History.md
Expand Up @@ -2,6 +2,7 @@
* Bugfixes
* Resolve issue with threadpool waiting counter decrement when thread is killed
* Constrain rake-compiler version to 0.9.4 to fix `ClassNotFound` exception when using MiniSSL with Java8.
* Fix recursive `prune_bundler` (#2319).

## 5.0.0

Expand Down
1 change: 1 addition & 0 deletions lib/puma/launcher.rb
Expand Up @@ -288,6 +288,7 @@ def puma_wild_location
end

def prune_bundler
return if ENV['PUMA_BUNDLER_PRUNED']
return unless defined?(Bundler)
require_rubygems_min_version!(Gem::Version.new("2.2"), "prune_bundler")
unless puma_wild_location
Expand Down
14 changes: 14 additions & 0 deletions test/config/prune_bundler_with_multiple_workers.rb
@@ -0,0 +1,14 @@
require 'bundler/setup'
Bundler.setup

prune_bundler true

workers 2

app do |env|
[200, {}, ["embedded app"]]
end

lowlevel_error_handler do |err|
[200, {}, ["error page"]]
end
24 changes: 24 additions & 0 deletions test/test_integration_cluster.rb
Expand Up @@ -198,6 +198,30 @@ def test_nakayoshi
assert output, "Friendly fork didn't run"
end

def test_prune_bundler_with_multiple_workers
cli_server "", config: <<RUBY
require 'bundler/setup'
Bundler.setup
prune_bundler true
workers 2
app do |env|
[200, {}, ["embedded app"]]
end
lowlevel_error_handler do |err|
[200, {}, ["error page"]]
end
RUBY

connection = connect
reply = read_body(connection)

assert reply, "embedded app"
end

private

def worker_timeout(timeout, iterations, config)
Expand Down
20 changes: 20 additions & 0 deletions test/test_integration_pumactl.rb
Expand Up @@ -90,6 +90,26 @@ def test_phased_restart_cluster
@server = nil
end

def test_prune_bundler_with_multiple_workers
skip NO_FORK_MSG unless HAS_FORK

cli_server "-q -C test/config/prune_bundler_with_multiple_workers.rb --control-url unix://#{@control_path} --control-token #{TOKEN} -S #{@state_path}", unix: true

s = UNIXSocket.new @bind_path
@ios_to_close << s
s << "GET / HTTP/1.0\r\n\r\n"

body = s.read

assert_match "200 OK", body
assert_match "embedded app", body

cli_pumactl "stop", unix: true

_, status = Process.wait2(@pid)
@server = nil
end

def test_kill_unknown
skip_on :jruby

Expand Down

0 comments on commit 39f9c72

Please sign in to comment.