mirror of
https://github.com/thegeeklab/wait-for.git
synced 2024-11-21 20:00:39 +00:00
set nc timeout to 1
This commit is contained in:
parent
5c19db4c9f
commit
b4ab35f3be
17
wait-for
17
wait-for
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user