wait-for.sh 207 B

1234567891011121314151617
  1. #!/bin/sh
  2. set -e
  3. host="$1"
  4. shift
  5. port="$1"
  6. shift
  7. cmd="$@"
  8. while ! nc -vz $host $port; do
  9. >&2 echo "waiting for $host:$port..."
  10. sleep 1
  11. done
  12. >&2 echo "$host:$port is up - executing command"
  13. exec $cmd