From 8f96279e4baf6143bdcdb5e93782fdcb4e4064bc Mon Sep 17 00:00:00 2001 From: "Ben Sheldon [he/him]" Date: Mon, 7 Aug 2023 22:26:46 -0700 Subject: [PATCH] Retry IO.select in Probe Server instead of returning early (#1034) --- lib/good_job/http_server.rb | 2 +- spec/lib/good_job/probe_server_spec.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/good_job/http_server.rb b/lib/good_job/http_server.rb index ec164b53c..a7435f618 100644 --- a/lib/good_job/http_server.rb +++ b/lib/good_job/http_server.rb @@ -44,7 +44,7 @@ def handle_connections while @running.true? begin ready_sockets, = IO.select([@server], nil, nil, SOCKET_READ_TIMEOUT) - return unless ready_sockets + next unless ready_sockets client = @server.accept_nonblock(exception: false) request = client.gets diff --git a/spec/lib/good_job/probe_server_spec.rb b/spec/lib/good_job/probe_server_spec.rb index b42df8788..b4687481a 100644 --- a/spec/lib/good_job/probe_server_spec.rb +++ b/spec/lib/good_job/probe_server_spec.rb @@ -24,6 +24,15 @@ ip_addresses.each do |ip_address| response = Net::HTTP.get(ip_address, "/", port) expect(response).to eq("OK") + + response = Net::HTTP.get(ip_address, "/status", port) + expect(response).to eq("OK") + + response = Net::HTTP.get(ip_address, "/status/started", port) + expect(response).to eq("Not started") + + response = Net::HTTP.get(ip_address, "/status/connected", port) + expect(response).to eq("Not connected") end end end