Wait for another service to become available

wait_for is a rust based cli designed to synchronize services such as docker containers. It is highly inspired by eficode/wait-for, but rewritten to use with rust.

Installation

To install the cli first you need to clone repository locally:

git clone https://github.com/aktitarov/wait_for.git && cd wait_for

Then install it to your path using cargo:

cargo install --path .

Usage

``` Waits for another service to become available

USAGE: wait_for [OPTIONS] --host --port [command]...

FLAGS: --help Prints help information -V, --version Prints version information

OPTIONS: -h, --host Sets host of service to be watched -p, --port Sets port of service to be watched -t, --timeout Sets timeout in secons, zero for no timeout

ARGS: ... Command to execute after service is available ```

Examples

To check if google.com is available:

wait_for -h www.google.com -p 80 -- echo "Google is up"

To wait for database container to become available:

``` version: '3'

service: database: image: postgres:latest app: build: . command: sh -c 'waitfor -h database -p 5432 -- ./target/release/app' dependson: - database ```

Note

Make sure netcat is installed in your Dockerfile before running the command.

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

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