Added two more options - wait time and also command to use for testing #106
+40
−9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.