Cross-platform command line utility and Node.js API which will wait for files, ports, sockets, and http(s) resources to become available
—
Command-line utility providing full access to wait-on functionality through CLI arguments and configuration files. Supports time interval parsing and environment-specific options.
wait-on [options] resource1 [resource2 ...]The CLI waits for all specified resources to become available, then exits with code 0 (success) or non-zero (error/timeout).
Usage Examples:
# Wait for single file
wait-on file1
# Wait for multiple resources
wait-on file1 file2 http://localhost:8000
# Chain with another command
wait-on http://localhost:3000 && npm start
# Wait for service shutdown in reverse mode
wait-on -r tcp:8080 && echo "Service stopped"# Configuration file (JavaScript or JSON)
-c, --config <file>
# Example usage
wait-on --config ./wait-config.jsConfiguration file format:
module.exports = {
resources: ['http://localhost:3000'],
timeout: 30000,
interval: 1000,
log: true,
// Any other options from the Node.js API
};# Initial delay before checking resources (ms)
-d, --delay <ms>
# Poll interval (supports time units: ms, s, m, h)
-i, --interval <time>
# Overall timeout (supports time units)
-t, --timeout <time>
# Stability window (supports time units), default 750ms
# Time that resource needs to have not changed before signaling success
# If less than interval, it will be reset to the value of interval
# This is only used for files, other resources are considered available on first detection
-w, --window <time>
# HTTP request timeout (ms), default 0 (uses OS default)
--httpTimeout <ms>
# TCP connection timeout (ms), default 300ms
--tcpTimeout <ms>Usage Examples:
# Wait 5 seconds before starting, check every 2 seconds
wait-on -d 5000 -i 2s http://localhost:3000
# 30 second timeout with custom intervals
wait-on -t 30s -i 500ms tcp:3306
# File stability window
wait-on -w 2s file:/tmp/output.log# Enable logging to stdout
-l, --log
# Enable verbose/debug logging
-v, --verbose
# Reverse mode - wait for resources to become unavailable
-r, --reverse
# Limit concurrent connections
-s, --simultaneous <count>
# Show help
-h, --helpUsage Examples:
# Verbose logging
wait-on -v http://localhost:3000
# Reverse mode with logging
wait-on -r -l tcp:8080
# Limit to 3 concurrent connections
wait-on -s 3 http://api1.com http://api2.com http://api3.comThe CLI supports human-readable time intervals for timing options:
# Time unit suffixes
ms # milliseconds (default)
s # seconds
m # minutes
h # hours
# Examples
--timeout 30s # 30 seconds
--interval 2m # 2 minutes
--delay 500ms # 500 milliseconds
--window 1h # 1 hourUsage Examples:
# Various time formats
wait-on --timeout 5m --interval 10s http://localhost:3000
wait-on --delay 30s --window 2m file:/tmp/data.json
wait-on -t 1h -i 30s tcp:database:5432Resources can be specified directly as command arguments or in configuration files:
# Command line resources (take precedence over config file)
wait-on resource1 resource2 resource3
# Resources from config file only
wait-on --config myconfig.js0 # Success - all resources became available
1 # Error - timeout, resource unavailable, or other errorUsage Examples:
# Use in shell scripts
if wait-on -t 30s http://localhost:3000; then
echo "Server is ready"
npm start
else
echo "Server failed to start" >&2
exit 1
fi
# Chain commands
wait-on tcp:5432 && wait-on http://localhost:8080 && echo "All services ready"Configuration files provide access to all Node.js API options:
// wait-config.js
module.exports = {
resources: [
'http://localhost:3000',
'tcp:database:5432'
],
timeout: 30000,
interval: 1000,
log: true,
// HTTP-specific options not available via CLI flags
auth: {
username: process.env.API_USER,
password: process.env.API_PASS
},
headers: {
'User-Agent': 'MyApp/1.0'
},
validateStatus: (status) => status < 500
};Usage:
wait-on --config wait-config.jswait-on --helpDisplays comprehensive usage information including:
Usage Examples:
# Complete examples for different scenarios
# Web application startup
wait-on tcp:3306 tcp:6379 && wait-on http://localhost:3000/health && echo "App ready"
# Microservices orchestration
wait-on http://auth:8080/health http://api:8080/health http://ui:3000 && echo "All services online"
# File processing pipeline
wait-on file:/input/data.csv && process-data && wait-on file:/output/results.json
# Development workflow
wait-on http://localhost:3000 && npm run test:e2e
# Docker container coordination
wait-on tcp:postgres:5432 && wait-on tcp:redis:6379 && npm startInstall with Tessl CLI
npx tessl i tessl/npm-wait-on