wait-for-it
wait-for-it copied to clipboard
Support multiple host:port parameters
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.
+1 for this
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```
@Forever-Young can you fix conflicts? 👍
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