Skip to content

Commit

Permalink
chore: update make wait-for-stack to use script
Browse files Browse the repository at this point in the history
  • Loading branch information
robcxyz committed Dec 6, 2023
1 parent f61b4ab commit b3fc1b3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 20 deletions.
21 changes: 1 addition & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,7 @@ clean: ## Delete the state of the chain
echo "Cleaned up..."

wait-for-stack:
@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
bash scripts/wait-for-stack.sh

all: clone-dependencies install-goloop up-stack wait-for-stack enable-debug create-wallet fund-wallet ## All the things

Expand Down
34 changes: 34 additions & 0 deletions scripts/wait-for-stack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

# Target port
port=9080
# Timeout in seconds (2 minutes)
timeout=120
# Start time
start_time=$(date +%s)

while true; do
# Check current time
current_time=$(date +%s)
# Calculate elapsed time
elapsed=$(( current_time - start_time ))

# Check if timeout has been reached
if [ $elapsed -ge $timeout ]; then
echo "Timeout reached. Exiting."
exit 1
fi

# Check if port 9080 is available using netcat
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

# Wait for a short period before retrying
sleep 2
done

0 comments on commit b3fc1b3

Please sign in to comment.