Wait for conditions (port, file, URL, process) in automation scripts
Project description
waitfor
Wait for conditions in automation scripts. Check for ports, files, URLs, or processes before continuing.
Installation
pip install waitfor-cli
Usage
Wait for a port to be open
# Wait for port 8080 on localhost
waitfor port 8080
# Wait for port on remote host
waitfor port 5432 -h db.example.com
# Wait for port to be CLOSED
waitfor port 8080 --closed
Wait for a file
# Wait for file to exist
waitfor file /tmp/ready.flag
# Wait for file to be gone
waitfor file /var/run/app.pid --gone
# Wait for file to contain specific content
waitfor file /var/log/app.log --contains "Server started"
Wait for a URL to respond
# Wait for health endpoint
waitfor url http://localhost:3000/health
# Wait for specific status code
waitfor url http://api.example.com/status --status 200
# Wait for response to contain string
waitfor url http://localhost:8080/ready --contains "ok"
Wait for a process
# Wait for process to start
waitfor process nginx
# Wait for process to stop
waitfor process nginx --gone
Wait for a command to succeed
# Wait for docker container to be healthy
waitfor command "docker inspect --format='{{.State.Health.Status}}' myapp | grep healthy"
# Wait for database to accept connections
waitfor command "pg_isready -h localhost"
Wait for remote TCP connection
# Wait for database to be reachable
waitfor tcp db.example.com 5432
# Wait for Redis
waitfor tcp localhost 6379
Options
All commands support these common options:
| Option | Description | Default |
|---|---|---|
-t, --timeout |
Timeout in seconds (0 = forever) | 30 |
-i, --interval |
Check interval in seconds | 1.0-2.0 |
-q, --quiet |
Suppress output | off |
--json |
JSON output | off |
Exit Codes
0- Condition met1- Timeout or condition not met
JSON Output
$ waitfor port 8080 --json
{"success": true, "condition": "port 8080 on localhost to be open", "elapsed_seconds": 0.01, "attempts": 1}
Examples
Wait for services before running tests
#!/bin/bash
waitfor port 5432 -t 60 && \
waitfor port 6379 -t 30 && \
waitfor url http://localhost:8080/health -t 60 && \
pytest
Deployment script
#!/bin/bash
docker-compose up -d
# Wait for all services
waitfor port 80 -t 120
waitfor url http://localhost/api/health --contains "healthy" -t 60
echo "Deployment complete!"
Wait for build artifact
# Start build in background
make build &
# Wait for output
waitfor file ./dist/app.js -t 300
For AI Agents
See SKILL.md for agent-optimized documentation.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
waitfor_cli-0.1.0.tar.gz
(6.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file waitfor_cli-0.1.0.tar.gz.
File metadata
- Download URL: waitfor_cli-0.1.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65150e961e6333b4dd1b2f369aed0d914642a9bc2aa01690ffdbab6e34773016
|
|
| MD5 |
9c67f95632b6332d6081b76018bb5b00
|
|
| BLAKE2b-256 |
cf7fcc211e6c7803fc3243ca0cc5099f7f4bf19435a5c02579c6a8d3a2d5106c
|
File details
Details for the file waitfor_cli-0.1.0-py3-none-any.whl.
File metadata
- Download URL: waitfor_cli-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53e6ae3c6c5ce767bdb6804fc60b291c4951d024c7f22b1976ce3cdce82d1dff
|
|
| MD5 |
04ed441272b5b4c2dc0d82111be7d316
|
|
| BLAKE2b-256 |
3b2eca6b32d673671091bb9981b7f2e8efdbae983c2186c8d73bbe3cd9d2596c
|