From 41deb2dbbe42066db8c9f246a84aab745ee04002 Mon Sep 17 00:00:00 2001 From: Giles Hall Date: Tue, 2 Feb 2016 14:30:19 -0500 Subject: [PATCH] small fixes --- README.md | 18 +++++++++++++++++- wait-for-it.sh | 5 ++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 80b3eb7..6f2935d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,23 @@ -= Wait for it +=Wait for it= wait-for-it.sh is a pure bash script that wait on the availability of a host and TCP port. It is useful for synchronizing the spin-up of interdependent services, such as linked docker containers. Since it is a pure bash script, it does not have any external dependencies. +==Usage== + +``` +wait-for-it.sh host:port [-s] [-t timeout] [-- command args] +-h HOST | --host=HOST Host or IP under test +-p PORT | --port=PORT TCP port under test + Alternatively, you specify the host and port as host:port +-s | --strict Only execute subcommand if the test succeeds +-q | --quiet Don't output any status messages +-t TIMEOUT | --timeout=TIMEOUT + Timeout in seconds, zero for no timeout +-- COMMAND ARGS Execute command with args after the test finishes +``` + +==Examples== + For example, let's test to see if we can access port 80 on www.google.com, and if it is available, echo the message "Let's start googling!" ``` diff --git a/wait-for-it.sh b/wait-for-it.sh index 7df6b16..3f80029 100755 --- a/wait-for-it.sh +++ b/wait-for-it.sh @@ -63,7 +63,7 @@ wait_for_wrapper() } # process arguments -while [[ $# -ne 0 ]] +while [[ $# -gt 0 ]] do case "$1" in *:* ) @@ -86,6 +86,7 @@ do ;; -h) HOST="$2" + if [[ $HOST == "" ]]; then break; fi shift 2 ;; --host=*) @@ -94,6 +95,7 @@ do ;; -p) PORT="$2" + if [[ $PORT == "" ]]; then break; fi shift 2 ;; --port=*) @@ -102,6 +104,7 @@ do ;; -t) TIMEOUT="$2" + if [[ $TIMEOUT == "" ]]; then break; fi shift 2 ;; --timeout=*)