wait-for-it icon indicating copy to clipboard operation
wait-for-it copied to clipboard

Support multiple host:port parameters

Open Forever-Young opened this issue 8 years ago • 5 comments

Forever-Young avatar Sep 28 '16 07:09 Forever-Young

I wouldn't do it this way; I'd use declare -A(associative array), to make the HOST:PORT connection more explicit. And I'd refactor the wait_for function to not act upon the global $HOST and $PORT variables.

eigood avatar Jan 17 '17 20:01 eigood

+1 for this

jpserra avatar Jul 14 '17 13:07 jpserra

I have a fix for the issue without making a lot of changes to this PR. We can add the following piece of code after the switch case

if [[ "${#HOSTS[*]}" == "0" || "${#PORTS[*]}" == "0" ]]; then
    echo "Not waiting for any endpoints. Starting java application"
    if [[ $CLI != "" ]]; then
        exec $CLI
    fi
fi

TIMEOUT=${TIMEOUT:-30}
STRICT=${STRICT:-0}
QUIET=${QUIET:-0}

for i in "${!HOSTS[@]}"; do
    HOST=${HOSTS[$i]}
    PORT=${PORTS[$i]}
    wait_for
    if [ $? -ne 0 ]; then
        echoerr "$HOST:$PORT did not start, exiting the script"
        exit $?
    fi
done
RESULT=$?


if [[ $CLI != "" ]]; then
    if [[ $RESULT -ne 0 && $STRICT -eq 1 ]]; then
        echoerr "$cmdname: strict mode, refusing to execute subprocess"
        exit $RESULT
    fi
    exec $CLI
else
    exit $RESULT
fi```

mayanand avatar Jul 17 '17 20:07 mayanand

@Forever-Young can you fix conflicts? 👍

brunowego avatar Mar 07 '19 14:03 brunowego

Hey @Forever-Young

You can use the Wait4X, It's already supported multiple host checking.

Example: wait4x tcp 1.1.1.1:80 1.1.1.1:53 --log-level debug

atkrad avatar Jun 15 '22 12:06 atkrad