wait-for.sh 238 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 "$host:$port is unavailable yet - waiting for it to start"
  10. sleep 10
  11. done
  12. >&2 echo "$host:$port is up - executing command"
  13. exec $cmd