All Projects → eficode → wait-for

eficode / wait-for

Licence: MIT license
./wait-for is a script to wait for another service to become available.

Projects that are alternatives of or similar to wait-for

iOSDC2020-Talk-Sample
iOSDC 2020「GitHub ActionsでiOSアプリをCIする個人的ベストプラクティス」レギュラートークのサンプルリポジトリ
Stars: ✭ 35 (-97.84%)
Mutual labels:  ci
gitavscan
Git Anti-Virus Scan Action - Detect trojans, viruses, malware & other malicious threats.
Stars: ✭ 23 (-98.58%)
Mutual labels:  ci
dohq-ai-best-practices
Внедрение и эксплуатация PT Application Inspector. Подробнее: https://habr.com/ru/company/pt/blog/557142/
Stars: ✭ 22 (-98.64%)
Mutual labels:  ci
keyval-resource
a resource that passes key values between jobs
Stars: ✭ 39 (-97.59%)
Mutual labels:  ci
circleci-config-sdk-ts
Generate CircleCI Configuration YAML from JavaScript or TypeScript. Use Dynamic Configuration and the Config SDK together for live generative config.
Stars: ✭ 59 (-96.35%)
Mutual labels:  ci
horusec-engine
Horusec analysis engine
Stars: ✭ 18 (-98.89%)
Mutual labels:  ci
ofcourse
A Concourse resource generator
Stars: ✭ 41 (-97.47%)
Mutual labels:  ci
ci-minikube
run minikube on ci
Stars: ✭ 28 (-98.27%)
Mutual labels:  ci
intelirest-cli
A cli interpreter for intelliJ .http files
Stars: ✭ 23 (-98.58%)
Mutual labels:  ci
testing
Testing in Go
Stars: ✭ 30 (-98.15%)
Mutual labels:  ci
kahoy
Simple Kubernetes raw manifests deployment tool
Stars: ✭ 33 (-97.96%)
Mutual labels:  ci
ansible-role-xcode
Ansible Role - Xcode
Stars: ✭ 27 (-98.33%)
Mutual labels:  ci
github-task-manager
receive github hook, notify agent, receive task results, notify github
Stars: ✭ 13 (-99.2%)
Mutual labels:  ci
unity-test-runner
Run tests for any Unity project
Stars: ✭ 134 (-91.72%)
Mutual labels:  ci
Infrastructure
Templates and assets used to launch and manage many aspects of PRX's applications and services
Stars: ✭ 40 (-97.53%)
Mutual labels:  ci
documentation
📚 Documentation for GameCI open source projects
Stars: ✭ 96 (-94.07%)
Mutual labels:  ci
setup-graalvm
No description or website provided.
Stars: ✭ 63 (-96.11%)
Mutual labels:  ci
ubuntu-vnc-xfce-g3
Headless Ubuntu/Xfce containers with VNC/noVNC (Generation 3)
Stars: ✭ 83 (-94.87%)
Mutual labels:  ci
gke-demo
Demonstration of complete, fully-featured CI/CD and cloud automation for microservices, done with GCP/GKE
Stars: ✭ 47 (-97.1%)
Mutual labels:  ci
flagsmith-java-client
Java Client for Flagsmith. Ship features with confidence using feature flags and remote config. Host yourself or use our hosted version at https://www.flagsmith.com/
Stars: ✭ 16 (-99.01%)
Mutual labels:  ci

wait-for

Wait for another service to become available
GitHub release (latest by date) Script file size
Example usage · Submit a PR

./wait-for is a script designed to synchronize services like docker containers. It is sh and alpine compatible. It was inspired by vishnubob/wait-for-it, but the core has been rewritten at Eficode by dsuni and mrako.

When using this tool, you only need to pick the wait-for file as part of your project.

Usage

Download the wait-for file, either the latest from master or for a specific version check out the Releases-page.

With the file locally on your file system, you can directly invoke it.

./wait-for host:port|url [-t timeout] [-- command args]
  -q | --quiet                        Do not output any status messages
  -t TIMEOUT | --timeout=timeout      Timeout in seconds, zero for no timeout
  -v | --version                      Show the version of this tool
  -- COMMAND ARGS                     Execute command with args after the test finishes

Alternatively, you could download the script and pipe it into sh:

$ wget -qO- https://raw.githubusercontent.com/eficode/wait-for/v2.2.3/wait-for | sh -s -- google.com:80 -- echo success

Note: When using the latter option, make sure to pin the version by commit hash. Future releases could introduce non-backwards compatible changes and leaves you vulnerable to malicious users modifying this script in the future (as has e.g. happened with Codecov).

This can also be easily used in GitHub Actions, like so:

      - name: Wait for the database to start
        run: wget -qO- https://raw.githubusercontent.com/eficode/wait-for/$WAIT_FOR_VERSION/wait-for | sh -s -- localhost:5132 -- echo "Database is up"
        env:
          WAIT_FOR_VERSION: 4df3f9262d84cab0039c07bf861045fbb3c20ab7 # v2.2.3

Examples

To check if www.eficode.com is available:

$ ./wait-for www.eficode.com:80 -- echo "Eficode site is up"
Eficode site is up

To wait for database container to become available:

version: "3"

services:
  db:
    image: postgres:9.4

  backend:
    build: backend
    command: sh -c './wait-for db:5432 -- npm start'
    depends_on:
      - db

To check if https://www.eficode.com is available over HTTPS:

$ ./wait-for https://www.eficode.com -- echo "Eficode is accessible over HTTPS"
Eficode is accessible over HTTPS

To wait for your API service to become available:

version: "3"

services:
  api:
    image: nginx

  tests:
    build: .
    command: sh -c './wait-for http://api -- echo "The api is up! Let's use it"'
    depends_on:
      - api

Testing

Ironically testing is done using bats, which on the other hand is depending on bash.

docker build -t wait-for .
docker run --rm -t wait-for

Contributing

When creating PRs, please style your commit messages according to conventional commit, you can use a tool like commitizen to guide you. We will automatically infer the changelog from your commits. Alternatively, we can squash all commits when merging and update the commit message.

This project strongly prefers maintaining backwards compatibility, therefore some obvious "fixes" might not be accepted.

Also, please include or update the test cases whenever possible by extending wait-for.bats.

Note

Make sure netcat is installed in your Dockerfile before running the command if you test over plain TCP.

RUN apt-get -q update && apt-get -qy install netcat

https://stackoverflow.com/questions/44663180/docker-why-does-wait-for-always-time-out

If you are connecting over HTTP, then you will need to have wget available.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].