Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
fmartin-linagora opened this issue Sep 26, 2019 · 6 comments

Comments

@fmartin-linagora
Copy link

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
Copy link
Author

May I propose this pull request ?

@aristosh
Copy link

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

@superkartoffel
Copy link

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"

@fmartin-linagora
Copy link
Author

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

@caryyu
Copy link

caryyu commented Mar 19, 2020

@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

@danielhanold
Copy link

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

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

No branches or pull requests

5 participants