Skip to content

Commit

Permalink
wait for it script added
Browse files Browse the repository at this point in the history
  • Loading branch information
jesussmariscal committed Dec 27, 2024
1 parent 2b1cb60 commit 66f129d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Backend/wait-for-it.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh

host=$1
port=$2
timeout=${3:-15} # Timeout por defecto de 15 segundos

start_time=$(date +%s)

while ! nc -z "$host" "$port"; do
sleep 1
elapsed_time=$(( $(date +%s) - start_time ))

if [[ $elapsed_time -ge $timeout ]]; then
echo "Timeout while waiting for $host:$port" >&2
exit 1
fi
done

echo "$host:$port is available"
exit 0

0 comments on commit 66f129d

Please sign in to comment.