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