From 5ba7be4ea462b167383f4316a1cda6021394d8c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20MARTIN?= Date: Thu, 26 Sep 2019 15:19:51 +0200 Subject: [PATCH] Adding and optional delay after the test succeeds to trigger the command. --- wait-for-it.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/wait-for-it.sh b/wait-for-it.sh index 071c2be..344ba16 100755 --- a/wait-for-it.sh +++ b/wait-for-it.sh @@ -17,6 +17,8 @@ Usage: -q | --quiet Don't output any status messages -t TIMEOUT | --timeout=TIMEOUT Timeout in seconds, zero for no timeout + -d delay | --delay=DELAY + Delay in seconds after the test succeeds to trigger the command. zero for no timeout (default). -- COMMAND ARGS Execute command with args after the test finishes USAGE exit 1 @@ -85,6 +87,10 @@ do WAITFORIT_QUIET=1 shift 1 ;; + -d | --delay) + WAITFORIT_DELAY=1 + shift 1 + ;; -s | --strict) WAITFORIT_STRICT=1 shift 1 @@ -140,6 +146,7 @@ WAITFORIT_TIMEOUT=${WAITFORIT_TIMEOUT:-15} WAITFORIT_STRICT=${WAITFORIT_STRICT:-0} WAITFORIT_CHILD=${WAITFORIT_CHILD:-0} WAITFORIT_QUIET=${WAITFORIT_QUIET:-0} +WAITFORIT_DELAY=${WAITFORIT_DELAY:-0} # check to see if timeout is from busybox? WAITFORIT_TIMEOUT_PATH=$(type -p timeout) @@ -172,6 +179,7 @@ if [[ $WAITFORIT_CLI != "" ]]; then echoerr "$WAITFORIT_cmdname: strict mode, refusing to execute subprocess" exit $WAITFORIT_RESULT fi + sleep ${WAITFORIT_DELAY} exec "${WAITFORIT_CLI[@]}" else exit $WAITFORIT_RESULT