Browse Source

Add retry message suppression in network.port_is_up function

main
Bastian (BaM) 3 months ago
parent
commit
50ac346030
  1. 8
      scripts/network.lua

8
scripts/network.lua

@ -60,6 +60,8 @@ function network.port_is_up(host, port, timeout_sec, check_interval_sec)
-- Implement timeout loop with short intervals
local start_time = os.time()
local retry_message_sent = false
while (os.time() - start_time) < timeout do
local cmd = string.format("nc -z -w1 %s %d 2>/dev/null", host, port)
local success, reason, code = os.execute(cmd)
@ -70,7 +72,11 @@ function network.port_is_up(host, port, timeout_sec, check_interval_sec)
-- Wait before next check
if (os.time() - start_time) < timeout then
utils.log("Port " .. port .. " not yet available on " .. host .. ", retrying in " .. check_interval_sec .. "s...")
if not retry_message_sent then
utils.log("Port " ..
port .. " not yet available on " .. host .. ", retrying every " .. check_interval_sec .. "s...")
retry_message_sent = true
end
os.execute("sleep " .. check_interval_sec)
end
end

Loading…
Cancel
Save