Add retry message suppression in network.port_is_up function
This commit is contained in:
@@ -60,6 +60,8 @@ function network.port_is_up(host, port, timeout_sec, check_interval_sec)
|
|||||||
-- Implement timeout loop with short intervals
|
-- Implement timeout loop with short intervals
|
||||||
local start_time = os.time()
|
local start_time = os.time()
|
||||||
|
|
||||||
|
local retry_message_sent = false
|
||||||
|
|
||||||
while (os.time() - start_time) < timeout do
|
while (os.time() - start_time) < timeout do
|
||||||
local cmd = string.format("nc -z -w1 %s %d 2>/dev/null", host, port)
|
local cmd = string.format("nc -z -w1 %s %d 2>/dev/null", host, port)
|
||||||
local success, reason, code = os.execute(cmd)
|
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
|
-- Wait before next check
|
||||||
if (os.time() - start_time) < timeout then
|
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)
|
os.execute("sleep " .. check_interval_sec)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user