aboutsummaryrefslogtreecommitdiffstats
path: root/mcp/scripts/lib.sh
diff options
context:
space:
mode:
Diffstat (limited to 'mcp/scripts/lib.sh')
-rw-r--r--mcp/scripts/lib.sh14
1 files changed, 11 insertions, 3 deletions
diff --git a/mcp/scripts/lib.sh b/mcp/scripts/lib.sh
index 63a5adc5a..e9dd30960 100644
--- a/mcp/scripts/lib.sh
+++ b/mcp/scripts/lib.sh
@@ -437,13 +437,21 @@ function wait_for {
local total_attempts=$1; shift
local cmdstr=$*
local sleep_time=10
- echo "[NOTE] Waiting for cmd to return success: ${cmdstr}"
+ echo "[wait_for] Waiting for cmd to return success: ${cmdstr}"
# shellcheck disable=SC2034
for attempt in $(seq "${total_attempts}"); do
- # shellcheck disable=SC2015
- eval "${cmdstr}" && return 0 || true
+ echo "[wait_for] Attempt ${attempt}/${total_attempts%.*} for: ${cmdstr}"
+ if [ "${total_attempts%.*}" = "${total_attempts}" ]; then
+ # shellcheck disable=SC2015
+ eval "${cmdstr}" && echo "[wait_for] OK: ${cmdstr}" && return 0 || true
+ else
+ ( eval "${cmdstr}" || echo __fuel_wf_failure__ ) |& tee /dev/stderr | \
+ grep -Eq '(Not connected|No response|__fuel_wf_failure__)' || \
+ echo "[wait_for] OK: ${cmdstr}" && return 0
+ fi
echo -n '.'; sleep "${sleep_time}"
done
+ echo "[wait_for] ERROR: Failed after max attempts: ${cmdstr}"
return 1
)
}