Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wjordan committed Feb 10, 2020
1 parent 56a5eb8 commit 04ca650
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
8 changes: 5 additions & 3 deletions lib/puma/cluster.rb
Expand Up @@ -111,7 +111,8 @@ def term
@signal = "KILL"
else
@term ||= true
@first_term_sent ||= Time.now
return if @first_term_sent
@first_term_sent = Time.now
end
Process.kill @signal, @pid
rescue Errno::ESRCH
Expand Down Expand Up @@ -271,6 +272,7 @@ def worker(index, master)
@launcher.config.run_hooks :before_worker_boot, index

server = start_server
server.run

Signal.trap "SIGTERM" do
@worker_write << "e#{Process.pid}\n" rescue nil
Expand Down Expand Up @@ -305,7 +307,7 @@ def worker(index, master)
end
end

server.run.join
server.thread.join

# Invoke any worker shutdown hooks so they can prevent the worker
# exiting until any background operations are completed
Expand Down Expand Up @@ -553,9 +555,9 @@ def run
private

def shutdown
@launcher.close_binder_listeners unless @restart
stop_control
stop_workers
@launcher.close_binder_listeners unless @restart
halt
end

Expand Down
18 changes: 8 additions & 10 deletions lib/puma/server.rb
Expand Up @@ -217,7 +217,6 @@ def run_lopez_mode(background=true)
def handle_servers_lopez_mode
begin
check = @check
handle_check
sockets = [check] + @binder.ios
pool = @thread_pool

Expand Down Expand Up @@ -365,7 +364,6 @@ def run(background=true)
def handle_servers
begin
check = @check
handle_check
sockets = [check] + @binder.ios
pool = @thread_pool
queue_requests = @queue_requests
Expand Down Expand Up @@ -439,21 +437,21 @@ def handle_servers

# :nodoc:
def handle_check
case @check.read_nonblock(1)
cmd = @check.read(1)

case cmd
when STOP_COMMAND
@status = :stop
true
return true
when HALT_COMMAND
@status = :halt
true
return true
when RESTART_COMMAND
@status = :restart
true
else
false
return true
end
rescue IO::WaitReadable
false

return false
end

# Given a connection on +client+, handle the incoming requests.
Expand Down
3 changes: 2 additions & 1 deletion lib/puma/single.rb
Expand Up @@ -108,6 +108,7 @@ def run
start_control

@server = server = start_server
server.run

unless daemon?
log "Use Ctrl-C to stop"
Expand All @@ -117,7 +118,7 @@ def run
@launcher.events.fire_on_booted!

begin
server.run.join
server.thread.join
rescue Interrupt
# Swallow it
end
Expand Down
3 changes: 1 addition & 2 deletions test/test_plugin.rb
Expand Up @@ -4,12 +4,11 @@
class TestPlugin < TestIntegration
def test_plugin
skip "Skipped on Windows Ruby < 2.5.0, Ruby bug" if windows? && RUBY_VERSION < '2.5.0'
@tcp_bind = UniquePort.call
@tcp_ctrl = UniquePort.call

Dir.mkdir("tmp") unless Dir.exist?("tmp")

cli_server "-b tcp://#{HOST}:#{@tcp_bind} --control-url tcp://#{HOST}:#{@tcp_ctrl} --control-token #{TOKEN} -C test/config/plugin1.rb test/rackup/hello.ru"
cli_server "--control-url tcp://#{HOST}:#{@tcp_ctrl} --control-token #{TOKEN} -C test/config/plugin1.rb test/rackup/hello.ru"
File.open('tmp/restart.txt', mode: 'wb') { |f| f.puts "Restart #{Time.now}" }

true while (l = @server.gets) !~ /Restarting\.\.\./
Expand Down

0 comments on commit 04ca650

Please sign in to comment.