wait-for-it icon indicating copy to clipboard operation
wait-for-it copied to clipboard

Enhancement: Add some opional delay between probing and runing a command

Open fmartin-linagora opened this issue 6 years ago • 6 comments

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 ?

fmartin-linagora avatar Sep 26 '19 13:09 fmartin-linagora

May I propose this pull request ?

fmartin-linagora avatar Sep 26 '19 13:09 fmartin-linagora

Yup, I agree. I'm having the same problem.

aristosh avatar Nov 13 '19 15:11 aristosh

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"

superkartoffel avatar Dec 19 '19 07:12 superkartoffel

Hello, yes i did this at first but it is a little bit more clutter.

fmartin-linagora avatar Jan 02 '20 14:01 fmartin-linagora

@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 avatar Mar 19 '20 14:03 caryyu

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

danielhanold avatar Aug 25 '22 14:08 danielhanold