An open API service indexing awesome lists of open source software.

https://github.com/hartwork/rust-for-it

:crab: Wait for one or more services (TCP ports) to be available before executing a command; Rust version of wait-for-it
https://github.com/hartwork/rust-for-it

command-line-tool rust rust-application tcp wait-for-it

Last synced: 3 months ago
JSON representation

:crab: Wait for one or more services (TCP ports) to be available before executing a command; Rust version of wait-for-it

Awesome Lists containing this project

README

          

[![Build and test](https://github.com/hartwork/rust-for-it/actions/workflows/build_and_test.yml/badge.svg)](https://github.com/hartwork/rust-for-it/actions/workflows/build_and_test.yml)
[![Enforce rustfmt-clean code](https://github.com/hartwork/rust-for-it/actions/workflows/enforce_rustfmt.yml/badge.svg)](https://github.com/hartwork/rust-for-it/actions/workflows/enforce_rustfmt.yml)

# rust-for-it

## About

**rust-for-it** is a lookalike of
(the perfectly fine)
Python [wait-for-it](https://github.com/clarketm/wait-for-it)
written in Rust 1.69+.

It supports waiting for multiple services concurrently by default,
and has a test coverage of >90%.
If you do find bugs, [please file a report](https://github.com/hartwork/rust-for-it/issues).
Thank you!

## Build and run

```console
$ cargo run -- --help
```

… or …

```console
$ cargo build
$ export PATH="${PWD}/target/debug:${PATH}"
$ rust-for-it --help
```

## Examples

```console
$ rust-for-it -t 2 -s [::1]:631 -s localhost:631 -s 127.0.0.1:631 -- echo 'CUPS is very available'
[*] Waiting 2 seconds for localhost:631...
[*] Waiting 2 seconds for [::1]:631...
[+] [::1]:631 is available after 0 seconds.
[*] Waiting 2 seconds for 127.0.0.1:631...
[+] 127.0.0.1:631 is available after 0 seconds.
[+] localhost:631 is available after 0 seconds.
CUPS is very available
```

## Usage

```console
$ rust-for-it --help
Wait for one or more services to be available before executing a command.

Usage: rust-for-it [OPTIONS] [command]...

Arguments:
[command]... Command to run after waiting;
includes command arguments, resolved against ${PATH}

Options:
-q, --quiet Do not output any status messages
-S, --strict Only execute if all services are found available [default: always executes]
-t, --timeout Timeout in seconds, 0 for no timeout [default: 15]
-s, --service [...] Service to test via the TCP protocol; can be passed multiple times
-h, --help Print help
-V, --version Print version
```

## Alternatives

### Go

- [`github.com/alioygur/wait-for`](https://github.com/alioygur/wait-for)
- [`github.com/hartwork/go-wait-for-it`](https://github.com/hartwork/go-wait-for-it)
- [`github.com/maxcnunes/waitforit`](https://github.com/maxcnunes/waitforit)
- [`github.com/mjeri/go-wait-for-it`](https://github.com/mjeri/go-wait-for-it)

### Python

- [`github.com/clarketm/wait-for-it`](https://github.com/clarketm/wait-for-it)
— package `wait-for-it` [on PyPI](https://pypi.org/project/wait-for-it/)
- [`github.com/David-Lor/python-wait4it`](https://github.com/David-Lor/python-wait4it/)
— package `wait4it` [on PyPI](https://pypi.org/project/wait4it/)

### Rust

- [`github.com/Etenil/wait-for-rust`](https://github.com/Etenil/wait-for-rust)
- [`github.com/hartwork/rust-for-it`](https://github.com/hartwork/rust-for-it) — the one you are looking at
- [`github.com/ktitaro/wait-for`](https://github.com/ktitaro/wait-for)
— package `wait_for` [on crates.io](https://crates.io/crates/wait_for)
- [`github.com/magiclen/wait-service`](https://github.com/magiclen/wait-service)
— package `wait-service` on [crates.io](https://crates.io/crates/wait-service)
- [`github.com/shenek/wait-for-them`](https://github.com/shenek/wait-for-them)
— package `wait-for-them` [on crates.io](https://crates.io/crates/wait-for-them)

### Shell

- [`github.com/eficode/wait-for`](https://github.com/eficode/wait-for)
— POSIX shell
- [`github.com/vishnubob/wait-for-it`](https://github.com/vishnubob/wait-for-it)
— Bash, package `wait-for-it` [in Debian](https://packages.debian.org/unstable/wait-for-it)