wait-for-it
wait-for-it copied to clipboard
Enhancement: Add some opional delay between probing and runing a command
Hi, I'm facing some issue when this script is probing a port to know if the service is up and running but sometimes the port is opened but the application is not yet ready.
Is it possible to add some sleep just after a successful check and running the command ?
May I propose this pull request ?
Yup, I agree. I'm having the same problem.
wouldn't it be just as easy to put the sleep command right in front of your actual command?
./wait-for-it.sh www.google.com:80 -- sleep 1; echo "google is up"
Hello, yes i did this at first but it is a little bit more clutter.
@superkartoffel your workaround didn't work for me in Kubernetes practice below(No issue without sleep 5;)
command:
- bash
- /scripts/wait-for-it.sh
- ${DATABASE_HOST}:${DATABASE_PORT}
- --timeout=30
- --
- sleep
- 5;
- bash
- /scripts/init.sh
So I'd rather give a vote for this
@caryyu Adding a sleep command won't work in containers when you use the exec form of the command, as none of the shell features are supported. I'm working around this by modifying the wait-for-it.sh scripts with the following sed command:
sed -i.bak "/exec.*WAITFORIT_CLI/i\ echo \"Extra startup delay: ${SCRIPT_STARTUP_DELAY:-5} seconds\"\n sleep ${SCRIPT_STARTUP_DELAY:-5}" /wait-for-it.sh
This adds a default delay of 5 seconds, which can be customized through the SCRIPT_STARTUP_DELAY environment variable.