Files
kami_merchant/deploy/wait-for-it.sh
2024-09-19 21:01:23 +08:00

14 lines
244 B
Bash

#!/bin/bash
set -x
host="${1%:*}"
port="${1#*:}"
shift
# shellcheck disable=SC2124
cmd="$@"
until nc -z "$host" "$port"; do
>&2 echo "Waiting for $host:$port to be available..."
sleep 1
done
>&2 echo "$host:$port is available!"
exec "$cmd"