Crates.io | waitup |
lib.rs | waitup |
version | 1.0.1 |
created_at | 2025-08-19 16:30:31.983197+00 |
updated_at | 2025-08-20 08:40:16.111662+00 |
description | Wait for TCP ports and HTTP endpoints to be available. Essential for Docker, K8s, and CI/CD pipelines to ensure services are ready before proceeding. |
homepage | https://github.com/grok-rs/waitup |
repository | https://github.com/grok-rs/waitup |
max_upload_size | |
id | 1802153 |
size | 365,351 |
waitup is a powerful TCP port checker and service health monitor that waits for services to become available. Essential for Docker, Kubernetes, CI/CD pipelines, and microservices orchestration. Replace wait-for-it
, dockerize
, and other dependency management tools with a single, fast, reliable solution.
Perfect for developers who need to:
Choose the best port checker and service health monitor:
Feature | waitup | dockerize | wait-on | wait-for-it |
---|---|---|---|---|
Language | Rust 🦀 | Go | Node.js | Bash |
HTTP Support | ✅ Full | ✅ Basic | ✅ Basic | ❌ None |
Custom Headers | ✅ Yes | ❌ No | ❌ No | ❌ No |
JSON Output | ✅ Yes | ❌ No | ❌ No | ❌ No |
Multiple Targets | ✅ Any/All | ❌ No | ✅ Basic | ❌ No |
DNS Resolution | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Binary Size | ~6MB | ~8MB | N/A | N/A |
Shell Completions | ✅ Yes | ❌ No | ❌ No | ❌ No |
Library Support | ✅ Rust | ❌ No | ❌ No | ❌ No |
Docker Ready | ✅ Alpine | ✅ Yes | ✅ Yes | ✅ Yes |
# Wait for PostgreSQL before running migrations
waitup postgres:5432 --timeout 60s -- npm run migrate
# Wait for multiple databases
waitup mysql:3306 redis:6379 postgres:5432 --all -- npm start
# Wait for external services before pod starts
waitup external-api:443 database:5432 --timeout 300s
# Ensure test services are ready
waitup localhost:5432 localhost:6379 --timeout 30s -- npm test
# Wait for API dependencies with custom headers
waitup https://auth-service/health --header "X-Health-Check:true" --expect-status 200
services:
app:
depends_on:
- db-ready
command: ["./app"]
db-ready:
image: waitup:alpine
command: ["waitup", "postgres:5432", "--timeout", "60s"]
The fastest way to get started with waitup:
# Clone and install in one step
git clone https://github.com/grok-rs/waitup.git && cd waitup && cargo install --path .
# Verify installation
waitup --version
# 1. Clone the repository
git clone https://github.com/grok-rs/waitup.git
cd waitup
# 2. Build and install
cargo install --path .
# 3. Verify installation
waitup --help
# Build the standard image
docker build -t waitup .
# Test it works
docker run --rm waitup --version
# Build Alpine image (recommended for production)
docker build -f Dockerfile.alpine -t waitup:alpine .
# Test it works
docker run --rm waitup:alpine --version
# Multi-stage build example
FROM rust:1.70 as builder
WORKDIR /app
COPY . .
RUN cargo build --release
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/release/waitup /usr/local/bin/waitup
ENTRYPOINT ["waitup"]
For contributing or development:
# Clone with full history
git clone https://github.com/grok-rs/waitup.git
cd waitup
# Install development dependencies
cargo build
# Run tests
cargo test
# Install for development
cargo install --path . --force
Enhance your command-line experience with auto-completions:
# Bash (system-wide)
sudo waitup --generate-completion bash > /usr/share/bash-completion/completions/waitup
# Bash (user-specific)
waitup --generate-completion bash > ~/.local/share/bash-completion/completions/waitup
# Zsh
waitup --generate-completion zsh > ~/.local/share/zsh/site-functions/_waitup
# Fish
waitup --generate-completion fish > ~/.config/fish/completions/waitup.fish
# PowerShell (Windows)
waitup --generate-completion powershell > waitup.ps1
Set default values to avoid repetitive flags:
# Add to your shell profile (.bashrc, .zshrc, etc.)
export WAITUP_TIMEOUT=60s
export WAITUP_INTERVAL=2s
# Now you can use shorter commands
waitup db:5432 # Uses your defaults
Confirm everything is working:
# Check version
waitup --version
# Test basic functionality
waitup google.com:80 --timeout 5s
# Verify completions (if installed)
waitup <TAB><TAB> # Should show available options
Command not found after installation:
# Ensure Cargo's bin directory is in your PATH
echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
Permission denied for shell completions:
# Use user-specific directories instead of system-wide
mkdir -p ~/.local/share/bash-completion/completions
waitup --generate-completion bash > ~/.local/share/bash-completion/completions/waitup
Docker build fails:
# Ensure you have the latest base images
docker pull rust:1.70
docker pull debian:bookworm-slim
# Wait for a service to be ready
waitup localhost:8080
# With timeout and custom interval
waitup db:5432 --timeout 2m --interval 5s
# Works with hostnames
waitup postgres-db:5432
waitup api.example.com:443
# Wait for all services (default)
waitup db:5432 redis:6379 api:8080
# Wait for any service to be ready
waitup primary-db:5432 backup-db:5432 --any
# HTTP endpoint health check
waitup https://api.example.com/health
# Custom status code expectation
waitup http://localhost:8080/ready --expect-status 204
# With custom headers (authentication, etc.)
waitup https://api.example.com/private --header "Authorization:Bearer token123" --header "X-API-Key:secret"
# Run command after successful connection
waitup db:5432 -- npm start
# Multiple services before command
waitup db:5432 redis:6379 --all -- ./start-app.sh
# Verbose mode with progress information
waitup db:5432 --verbose
# Quiet mode (no output)
waitup db:5432 --quiet
# JSON output for CI/CD integration
waitup db:5432 redis:6379 --json
# Custom backoff configuration
waitup slow-service:8080 --interval 1s --max-interval 30s
Configure defaults using environment variables:
export WAITUP_TIMEOUT=60s
export WAITUP_INTERVAL=2s
waitup db:5432 # Uses env defaults
0
: Success - all targets are reachable1
: Timeout - failed to connect within timeout period2
: Invalid arguments or configuration3
: Command execution failed (when using --
syntax)services:
app:
image: myapp
depends_on:
- db
command: ["waitup", "db:5432", "--", "npm", "start"]
db:
image: postgres
initContainers:
- name: waitup-db
image: waitup:latest
command: ["waitup", "postgres:5432", "--timeout", "5m"]
# Wait for test database before running tests
waitup localhost:5432 --timeout 30s -- npm test
# Wait for multiple dependencies
waitup \
auth-service:8001 \
user-service:8002 \
https://payment-api/health \
--all \
--timeout 2m \
-- ./start-gateway.sh
Supports human-readable durations:
30s
- 30 seconds2m
- 2 minutes1h30m
- 1 hour 30 minutes500ms
- 500 millisecondscargo test
# Limit retry attempts
waitup flaky-service:8080 --retry-limit 5
# Custom connection timeout per attempt
waitup slow-service:8080 --connection-timeout 30s
# Perfect for CI/CD pipelines
waitup api:8080 db:5432 --json | jq '.success'
# Example JSON output:
{
"success": true,
"elapsed_ms": 2341,
"total_attempts": 3,
"targets": [
{
"target": "api:8080",
"success": true,
"elapsed_ms": 1205,
"attempts": 2,
"error": null
}
]
}
You can use waitup as a Rust library in your applications. Check the source code and documentation in the repository for API details.
apiVersion: v1
kind: Pod
spec:
initContainers:
- name: waitup-deps
image: waitup:alpine
command: ["waitup"]
args: ["postgres:5432", "redis:6379", "--timeout", "300s"]
containers:
- name: app
image: myapp:latest
version: "3.8"
services:
app:
image: myapp:latest
depends_on:
db-ready:
condition: service_completed_successfully
db-ready:
image: waitup:alpine
command: ["waitup", "postgres:5432", "--timeout", "60s"]
depends_on:
- postgres
postgres:
image: postgres:15
Option | Environment Variable | Description |
---|---|---|
--timeout |
WAITUP_TIMEOUT |
Total timeout (default: 30s) |
--interval |
WAITUP_INTERVAL |
Initial retry interval (default: 1s) |
--max-interval |
- | Maximum retry interval (default: 30s) |
--connection-timeout |
- | Per-attempt timeout (default: 10s) |
--retry-limit |
- | Maximum retry attempts |
--expect-status |
- | Expected HTTP status (default: 200) |
Use waitup database:5432 --timeout 60s -- your-app-command
to wait for PostgreSQL, MySQL, or any database before starting your application.
waitup hostname:port --timeout 10s
Returns exit code 0 if successful, 1 if timeout, 2 for invalid arguments.
# Wait for ALL services (default)
waitup db:5432 redis:6379 api:8080 -- npm start
# Wait for ANY service to be ready
waitup primary-db:5432 backup-db:5432 --any -- npm start
Yes! waitup is a modern replacement with better features:
waitup https://api.example.com/health \
--header "Authorization:Bearer $TOKEN" \
--header "X-API-Key:$API_KEY" \
--expect-status 200
Yes! waitup supports both IPv4 and IPv6 through Rust's standard networking stack. Use IPv6 addresses normally: waitup [::1]:8080
Feature | waitup | dockerize |
---|---|---|
HTTP Headers | ✅ Yes | ❌ No |
JSON Output | ✅ Yes | ❌ No |
Multiple Strategies | ✅ Any/All | ❌ Sequential |
Language | Rust | Go |
Binary Size | ~6MB | ~8MB |
docker ps
or kubectl get pods
--verbose
flag to see connection attemptsAbsolutely! Perfect for waiting for external dependencies:
initContainers:
- name: wait-for-db
image: waitup:alpine
command: ["waitup", "postgres:5432", "--timeout", "300s"]
Use HTTP health checks instead of TCP:
# Instead of: waitup api:8080
# Use health endpoint:
waitup https://api:8080/health --expect-status 200
# Problem: Service not accepting connections yet
# Solution: Increase timeout and add verbose logging
waitup database:5432 --timeout 120s --verbose
# For Docker: Ensure containers are on same network
docker network ls
# Problem: Default timeout too short
# Solution: Increase timeout and interval
waitup slow-service:8080 --timeout 5m --interval 10s --max-interval 30s
# Problem: App starts before database ready
# Solution: Use waitup in entrypoint
services:
app:
entrypoint: ["waitup", "postgres:5432", "--", "npm", "start"]
depends_on:
- postgres
# Problem: External dependencies not ready
# Solution: Add waitup init container
initContainers:
- name: wait-deps
image: waitup:alpine
command: ["waitup", "external-api:443", "database:5432"]
# Problem: API returns 503 during startup
# Solution: Wait for specific status or use different endpoint
waitup https://api/ready --expect-status 204
# OR
waitup https://api/health --header "Accept:application/json"
# Problem: Tests failing because services not ready
# Solution: Add explicit wait with JSON output
waitup localhost:5432 localhost:6379 --json --timeout 60s
if [ $? -eq 0 ]; then npm test; fi
./wait-for-it.sh host:port
with waitup host:port
dockerize -wait tcp://host:port
with waitup host:port
wait-on tcp:host:port
with waitup host:port
We welcome contributions! Please see CONTRIBUTING.md for details.
Built with Rust for high performance, low memory usage, and fast startup times.
waitup follows security best practices:
See SECURITY.md for vulnerability reporting.
MIT License - see LICENSE file for details.