A small utility to wait for network peer availability. It polls each address and port, sleeping between runs.
Designed to be used in docker, specifically docker-compose, containers that need to wait for linked containers to be ready.
Hostname lookups and IPv6 are supported, and you can give each service your own name. Currently only TCP sockets are supported.
An AlpineLinux Package
is available. (Currently in the @edge
repository.)
-q
:- Quiets the output to only announce when a port is ready for connection.
-s <interval_seconds>
:- (Default: 1) specifies the number of seconds to sleep between rounds.
-t <timeout_seconds>
:- (Default: 0) specifies the minimum number of seconds to run before giving up and erroring out. If set to 0, no timeout is used and wait4ports will wait forever.
Options can also be enabled via environment variables:
WAIT4PORTS_VERBOSE
:-
Verbosity is on by default, but setting this value to
0
,n[o]
,f[alse]
, orof[f]
will disable it. WAIT4PORTS_SLEEP
:- (Default: 1) specify the number of seconds to sleep between rounds.
WAIT4PORTS_TIMEOUT
:- (Default: 0) specify the minimum number of seconds to run before giving up and erroring out. If set to 0, no timeout is used and wait4ports will wait forever.
wait4ports [-q] [-s <interval_seconds>] [-t <timeout_seconds>] \
[name=]tcp://<host_or_ip>:<port_or_service> \
[[name=]tcp://<host_or_ip>:<port_or_service>…]
wait4ports -q -t 60 tcp://redis:6379 loadbalancer=tcp://172.17.0.1:http