{"id":13587740,"url":"https://github.com/adrian-gheorghe/wait","last_synced_at":"2026-03-11T02:31:48.005Z","repository":{"id":144332484,"uuid":"149511268","full_name":"adrian-gheorghe/wait","owner":"adrian-gheorghe","description":"This script waits for a host or multiple hosts to respond on a TCP port but can also wait for a command to output a value.","archived":false,"fork":false,"pushed_at":"2020-09-29T05:36:01.000Z","size":9,"stargazers_count":11,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-02-13T21:56:04.748Z","etag":null,"topics":["bash","bash-script","shell","tcp"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adrian-gheorghe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-19T20:56:25.000Z","updated_at":"2024-08-01T16:33:45.267Z","dependencies_parsed_at":null,"dependency_job_id":"a35fbf88-d22b-40d3-b2ac-8a3260a9f8af","html_url":"https://github.com/adrian-gheorghe/wait","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adrian-gheorghe%2Fwait","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adrian-gheorghe%2Fwait/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adrian-gheorghe%2Fwait/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adrian-gheorghe%2Fwait/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adrian-gheorghe","download_url":"https://codeload.github.com/adrian-gheorghe/wait/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247740842,"owners_count":20988279,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","bash-script","shell","tcp"],"created_at":"2024-08-01T15:06:20.505Z","updated_at":"2026-03-11T02:31:47.986Z","avatar_url":"https://github.com/adrian-gheorghe.png","language":"Shell","funding_links":[],"categories":["Shell"],"sub_categories":[],"readme":"## wait.sh\n\n`wait.sh` is a bash script inspired by https://github.com/vishnubob/wait-for-it and https://github.com/eficode/wait-for\nThe script waits for a host or multiple hosts to respond on a TCP port but can also wait for a command to output a value. For example you can wait for a file to exist or contain something.\n\nThe script is mainly useful to link containers that dependend on one another to start. For example you can have a container that runs install scripts that will have to wait for the database to be accessible.\n\n## Requirements\nnetcat - The machine / container running wait.sh needs to have the netcat service installed.\n\n## Usage\n\n```\n./wait.sh --help\nwait.sh [[-w | --wait \"host:port\"] | [[-w | --wait \"ls -al /var/www\"] | [[-c | --command \"printenv\"] | [[-t | --timeout 10] | [-h | --help]]\n-w \"HOST:PORT\" | --wait \"HOST:PORT\"             You can specify the HOST and TCP PORT to test \n-w \"ls -al /var/www\" | --wait \"ls -al /var/www\" Alternatively you can specify a bash command that should return something\n-c \"printenv\" | --command \"printenv\"            Command that should be run when all waits are accessible. Multiple commands can be added\n-t TIMEOUT | --timeout=TIMEOUT                  Timeout untill script is killed. Not interval between calls\n-i INTERVAL | --interval=INTERVAL               Interval between calls\n-h | --help                                     Usage / Help\n```\n\n## Examples shell\n\n```\n$ ./wait.sh --wait \"database_host:3306\" --wait \"ls -al /var/www/html | grep docker-compose.yml\" --command \"Database is up and files exist\"\n$ ./wait.sh --wait \"database_host:3306\" --wait \"database_host2:3306\" --command \"echo \\\"Databases are up\\\"\"\n```\n\nYou can set your own timeout with the `-t` or `--timeout=` option.  Setting the timeout value to 0 will disable the delay between requests:\n\n```\n$ ./wait.sh --wait \"database_host:3306\" --wait \"database_host2:3306\" --command \"echo \\\"Databases are up\\\"\" --timeout 15\n```\n## Examples docker-compose\n\n```\nversion: '3.3'\nservices:\n  db:\n    image: mysql:5.7\n    deploy:\n    environment:\n      MYSQL_ROOT_PASSWORD: root\n      MYSQL_DATABASE: database\n  wait:\n    build:\n      context: .\n    command: \"./wait.sh --wait \\\"db:3306\\\" --command \\\"ls -al\\\"\"\n    \n```\n\n## Example docker multiple FROM\n\nIn the following example the Dockerfile adds the wait.sh file from the adighe/wait container. \nThe setup allows the running of database migrations only after the database is accessible and the volume is mounted\n\n### Dockerfile\n```\n\nFROM adighe/wait as wait\nFROM php:7.1.3-fpm\n\n# Install dependencies\nRUN apt-get update \\\n  \u0026\u0026 apt-get install -y \\\n    netcat\n\nRUN curl -sS https://getcomposer.org/installer | php \u0026\u0026 \\\n    mv composer.phar /usr/local/bin/composer\n\nCOPY --from=wait /app/wait.sh /app/wait.sh\n\nENTRYPOINT [\"docker-php-entrypoint\"]\nCMD [\"php-fpm\"]\n    \n```\n### docker-compose.yml\n```\n\nversion: '3.3'\nservices:\n  db:\n    image: mysql:5.7\n    deploy:\n    environment:\n      MYSQL_ROOT_PASSWORD: root\n      MYSQL_DATABASE: database\n  install:\n      build:\n        context: .\n      command: \"/bin/bash -c \\\"/app/wait.sh --wait 'db:3306' --wait 'ls -al /var/www/html/ | grep composer.json' --command 'cd /var/www/html' --command 'ls -al' --command 'composer install' --command 'php /var/www/html/bin/console doctrine:migrations:migrate -n -vvv'\\\"\"\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadrian-gheorghe%2Fwait","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadrian-gheorghe%2Fwait","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadrian-gheorghe%2Fwait/lists"}