set nc timeout to 1

This commit is contained in:
Robert Kaussow 2020-02-03 22:53:25 +01:00
parent 5c19db4c9f
commit b4ab35f3be

View File

@ -10,18 +10,21 @@ echoerr() {
usage() {
exitcode="$1"
cat << USAGE >&2
Usage:
$0 host:port [-t timeout] [-- command args]
-q | --quiet Do not output any status messages
-t WAITFOR_TIMEOUT | --timeout=timeout Timeout in seconds, zero for no timeout
-- COMMAND ARGS Execute command with args after the test finishes
usage: wait-for host:port [-t timeout] [-- command args]
Synchronize services like docker containers and wait for readiness.
optional arguments:
-q | --quiet Do not output any status messages
-t WAITFOR_TIMEOUT | --timeout=timeout Timeout in seconds, zero for no timeout
-- COMMAND ARGS Execute command with args after the test finishes
USAGE
exit "$exitcode"
}
wait_for() {
for _ in $(seq $WAITFOR_TIMEOUT) ; do
nc -z "$WAITFOR_HOST" "$WAITFOR_PORT" > /dev/null 2>&1
for _ in $(seq "$WAITFOR_TIMEOUT") ; do
nc -w 1 -z "$WAITFOR_HOST" "$WAITFOR_PORT" > /dev/null 2>&1
result=$?
if [ $result -eq 0 ] ; then