Delay startup parameter

It's useful when you want to wait a bit when port is available (ie. when connecting to Oracle or MySQL)
pull/46/head
Michał Zubkowicz 7 years ago committed by GitHub
parent db049716e4
commit f919f9c8c8

@ -14,6 +14,7 @@ Usage:
-p PORT | --port=PORT TCP port under test -p PORT | --port=PORT TCP port under test
Alternatively, you specify the host and port as host:port Alternatively, you specify the host and port as host:port
-s | --strict Only execute subcommand if the test succeeds -s | --strict Only execute subcommand if the test succeeds
-d | --delay Delay startup in seconds
-q | --quiet Don't output any status messages -q | --quiet Don't output any status messages
-t TIMEOUT | --timeout=TIMEOUT -t TIMEOUT | --timeout=TIMEOUT
Timeout in seconds, zero for no timeout Timeout in seconds, zero for no timeout
@ -51,6 +52,9 @@ wait_for()
wait_for_wrapper() wait_for_wrapper()
{ {
if [[ $DELAY -gt 0 ]]; then
sleep $DELAY
fi
# In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692 # In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692
if [[ $QUIET -eq 1 ]]; then if [[ $QUIET -eq 1 ]]; then
timeout $BUSYTIMEFLAG $TIMEOUT $0 --quiet --child --host=$HOST --port=$PORT --timeout=$TIMEOUT & timeout $BUSYTIMEFLAG $TIMEOUT $0 --quiet --child --host=$HOST --port=$PORT --timeout=$TIMEOUT &
@ -106,6 +110,15 @@ do
--port=*) --port=*)
PORT="${1#*=}" PORT="${1#*=}"
shift 1 shift 1
;;
-d)
DELAY="$2"
if [[ $DELAY == "" ]]; then break; fi
shift 2
;;
--delay=*)
DELAY="${1#*=}"
shift 1
;; ;;
-t) -t)
TIMEOUT="$2" TIMEOUT="$2"

Loading…
Cancel
Save