Skip to content

Commit

Permalink
make restart via pumactl more robust (#1324)
Browse files Browse the repository at this point in the history
  • Loading branch information
grosser authored and nateberkopec committed Jun 4, 2017
1 parent 290c22c commit 65a51b5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
1 change: 1 addition & 0 deletions test/helper.rb
Expand Up @@ -13,6 +13,7 @@
require "minitest/pride"

$LOAD_PATH << File.expand_path("../../lib", __FILE__)
Thread.abort_on_exception = true

require "puma"
require "puma/detect"
Expand Down
34 changes: 14 additions & 20 deletions test/test_integration.rb
Expand Up @@ -133,23 +133,17 @@ def test_phased_restart_via_pumactl
skip "Too finicky, fails 50% of the time on CI" if ENV["CI"]
skip if Puma.jruby? || Puma.windows?

conf = Puma::Configuration.new do |c|
c.quiet
c.state_path @state_path
c.bind "unix://#{@bind_path}"
c.activate_control_app "unix://#{@control_path}", :auth_token => @token
c.workers 2
c.worker_shutdown_timeout 1
c.rackup "test/rackup/hello-stuck.ru"
end

l = Puma::Launcher.new conf, :events => @events

Thread.abort_on_exception = true

t = Thread.new do
Thread.current.abort_on_exception = true
l.run
launcher_thread = Thread.new do
conf = Puma::Configuration.new do |c|
c.quiet
c.state_path @state_path
c.bind "unix://#{@bind_path}"
c.activate_control_app "unix://#{@control_path}", :auth_token => @token
c.workers 2
c.worker_shutdown_timeout 1
c.rackup "test/rackup/hello-stuck.ru"
end
Puma::Launcher.new(conf, :events => @events).run
end

wait_booted
Expand All @@ -161,7 +155,7 @@ def test_phased_restart_via_pumactl
sout = StringIO.new

# Phased restart
ccli = Puma::ControlCLI.new %W!-S #{@state_path} phased-restart!, sout
ccli = Puma::ControlCLI.new ["-S", @state_path, "phased-restart"], sout
ccli.run
sleep 20
@events.stdout.rewind
Expand All @@ -170,10 +164,10 @@ def test_phased_restart_via_pumactl
assert_match(/- Worker \d \(pid: \d+\) booted, phase: 1/, log)

# Stop
ccli = Puma::ControlCLI.new %W!-S #{@state_path} stop!, sout
ccli = Puma::ControlCLI.new ["-S", @state_path, "stop"], sout
ccli.run

assert_kind_of Thread, t.join(5), "server didn't stop"
assert_kind_of Thread, launcher_thread.join(5), "server didn't stop"
end

def test_kill_unknown_via_pumactl
Expand Down

0 comments on commit 65a51b5

Please sign in to comment.