2 releases
0.1.1 | Nov 12, 2019 |
---|---|
0.1.0 | Nov 12, 2019 |
#8 in #healthcheck
7KB
127 lines
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 <host> --port <port> [command]...
FLAGS:
--help Prints help information
-V, --version Prints version information
OPTIONS:
-h, --host <host> Sets host of service to be watched
-p, --port <port> Sets port of service to be watched
-t, --timeout <timeout> Sets timeout in secons, zero for no timeout
ARGS:
<command>... 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 'wait_for -h database -p 5432 -- ./target/release/app'
depends_on:
- 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
Dependencies
~1.5MB
~24K SLoC