| Crates.io | wait-for-rs |
| lib.rs | wait-for-rs |
| version | 0.1.1 |
| created_at | 2025-09-20 14:26:41.916481+00 |
| updated_at | 2025-09-20 15:04:25.094621+00 |
| description | A simple CLI to wait for a service to be available before executing a command |
| homepage | |
| repository | https://github.com/poi2/wait-for-rs |
| max_upload_size | |
| id | 1847815 |
| size | 82,176 |
A simple CLI to wait for a service to be available before executing a command.
wait-for is a Rust rewrite of the popular eficode/wait-for shell script. It provides a reliable way to wait for network services to become available, which is especially useful in Docker Compose setups and CI/CD pipelines.
netcat or wget requiredcargo install wait-for-rs
Download pre-compiled binaries from the GitHub Releases page.
# Copy the binary into your Docker image
COPY wait-for /usr/local/bin/wait-for
RUN chmod +x /usr/local/bin/wait-for
# Use it in your entrypoint
ENTRYPOINT ["wait-for", "db:5432", "--", "./start-app.sh"]
Wait for a TCP service:
wait-for db:5432
Wait for an HTTP service:
wait-for https://api.example.com/health
Execute a command after service is ready:
wait-for redis:6379 -- ./run-tests.sh
With custom timeout:
wait-for -t 30 postgres:5432 -- python manage.py migrate
Silent mode:
wait-for -q api:8080 -- curl http://api:8080/status
version: "3.8"
services:
db:
image: postgres:13
environment:
POSTGRES_PASSWORD: password
web:
image: myapp:latest
depends_on:
- db
command: ["wait-for", "db:5432", "--", "python", "manage.py", "runserver"]
- name: Wait for test database
run: wait-for localhost:5432 -- npm run test
test:
script:
- wait-for redis:6379 -- pytest tests/
A simple CLI to wait for a service to be available before executing a command
Usage: wait-for [OPTIONS] <TARGET> [COMMAND]...
Arguments:
<TARGET> Service to wait for (host:port or URL)
[COMMAND]... Command to execute after successful wait
Options:
-t, --timeout <TIMEOUT> Timeout in seconds (0 for no timeout) [default: 15]
-q, --quiet Quiet mode - suppress output
-h, --help Print help
-V, --version Print version
host:port (e.g., localhost:3306, redis:6379)https://api.example.com/health, http://localhost:8080/ready)0: Service is available (and command executed successfully if provided)1: Timeout reached or connection failed# Wait for PostgreSQL and run migrations
wait-for postgres:5432 -- python manage.py migrate
# Wait for MySQL and seed data
wait-for mysql:3306 -- npm run db:seed
# Wait for API service before running tests
wait-for api:8080 -- npm run integration-tests
# Chain multiple service dependencies
wait-for redis:6379 && wait-for postgres:5432 -- ./start-worker.sh
# Wait for HTTP health endpoint
wait-for https://api.example.com/health -- curl -f https://api.example.com/data
# Custom timeout for slow services
wait-for -t 60 elasticsearch:9200 -- python index_data.py
git clone https://github.com/poi2/wait-for-rs.git
cd wait-for-rs
cargo build --release
The binary will be available at target/release/wait-for.
| Feature | wait-for (shell) | wait-for (Rust) |
|---|---|---|
| Dependencies | netcat/wget required | None (self-contained) |
| Platform support | Unix-like only | Linux/macOS/Windows |
| Binary size | N/A (script) | ~2MB static binary |
| Performance | Depends on external tools | Native compiled speed |
| Error messages | Basic | Detailed with context |
Contributions are welcome! Please feel free to submit a Pull Request.
This project is dual-licensed under either:
at your option.