From 2260aabac5c175c0260a70c1be7f0456cb378ec3 Mon Sep 17 00:00:00 2001 From: robcxyz Date: Wed, 6 Dec 2023 15:47:42 +0700 Subject: [PATCH] chore: improve port waiting in makefile --- Makefile | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 5f3c07b..ae558b6 100644 --- a/Makefile +++ b/Makefile @@ -50,8 +50,27 @@ clean: ## Delete the state of the chain echo "Cleaned up..." wait-for-stack: - echo Waiting for stack to come up - sleep 15 + @port=9080; \ + timeout=120; \ + start_time=$$(date +%s); \ + while true; do \ + current_time=$$(date +%s); \ + elapsed=$$(( current_time - start_time )); \ + if [ $$elapsed -ge $$timeout ]; then \ + echo "Timeout reached. Exiting."; \ + exit 1; \ + fi; \ + nc -z localhost $$port; \ + if [ $$? -eq 0 ]; then \ + echo "Port $$port is available."; \ + sleep 5 + exit 0; \ + else \ + echo "Port $$port is not available yet. Retrying..."; \ + fi; \ + sleep 5; \ + done + all: clone-dependencies install-goloop up-stack wait-for-stack enable-debug create-wallet fund-wallet ## All the things