Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple host:port parameters #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Forever-Young
Copy link

No description provided.

@eigood
Copy link

eigood commented Jan 17, 2017

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.

@jpserra
Copy link

jpserra commented Jul 14, 2017

+1 for this

@mayanand
Copy link

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```

@brunowego
Copy link

@Forever-Young can you fix conflicts? 👍

@atkrad
Copy link

atkrad commented Jun 15, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants