Skip to content

Conversation

@kopili
Copy link

@kopili kopili commented Feb 9, 2021

Added two more options to the script - First is 'wait time', which allows to specify time interval between each polling - previously it was hardcoded to 1 sec. Second option is 'command' - this allows you to test not only for port being open, but also to execute some testing command / script. For example, you might want to wait, until a REST API server becomes alive - you can have a script that makes calls to this server in order to check if it is alive and with the new option you can call this script and wait until it returns success as return code. Here is some sample usage in ENTRYPOINT: ENTRYPOINT [./wait-for-it.sh, -t, 0, -w, 60, -c, ./check_if_api_is_alive.sh, --, npm, start]. And here is how 'check_if_api_is_alive.sh' script might look like - 'curl --fail --silent localhost:8888/application/health | grep UP || exit 1'
Also added some message printing during the script operation in order to improve its usability / troubleshooting.

…lows to specify time interval between each polling - previously it was hardcoded to 1 sec. Second option is 'command' - this allows you to test not only for port being open, but also to execute some testing command / script. For example, you might want to wait, until a REST API server becomes alive - you can have a script that makes calls to this server in order to check if it is alive and with the new option you can call this script and wait until it returns success as return code. Here is some sample usage in ENTRYPOINT: ENTRYPOINT [./wait-for-it.sh, -t, 0, -w, 60, -c, ./check_if_api_is_alive.sh, --, npm, start]. And here is how 'check_if_api_is_alive.sh' script might look like - 'curl --fail --silent localhost:8888/application/health | grep UP || exit 1'
wait-for-it.sh Outdated
Alternatively, you specify the host and port as host:port
-c COMMAND | --command=COMMAND
A single command to test
-w TIMEOUT | --wait=TIMEOUT Wait / sleep time between each test attempt
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait is a very confusing choice of wording in this context. Maybe call it something like interval instead?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, I renamed the name of the option.

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.

2 participants