Skip to content

Instantly share code, notes, and snippets.

@rhamaa
Created November 18, 2021 04:16
Show Gist options
  • Save rhamaa/ef4280e813cce714b25d426d779096ef to your computer and use it in GitHub Desktop.
Save rhamaa/ef4280e813cce714b25d426d779096ef to your computer and use it in GitHub Desktop.
Waiting for TCP connection is up using simple bash script
#!/bin/sh
# source : https://github.com/aanand/docker-wait/blob/master/wait
set -e
host=$(env | grep _TCP_ADDR | cut -d = -f 2)
port=$(env | grep _TCP_PORT | cut -d = -f 2)
echo -n "waiting for TCP connection to $host:$port..."
while ! nc -w 1 $host $port 2>/dev/null
do
echo -n .
sleep 1
done
echo 'ok'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment