Skip to content

erikogan/wait4ports

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wait4ports

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.)

Options

-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.

Environment

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.

Usage

wait4ports [-q] [-s <interval_seconds>] [-t <timeout_seconds>] \
           [name=]tcp://<host_or_ip>:<port_or_service> \
           [[name=]tcp://<host_or_ip>:<port_or_service>…]

Example

wait4ports -q -t 60 tcp://redis:6379 loadbalancer=tcp://172.17.0.1:http

About

A small utility to wait for network peer availability

Resources

License

Stars

Watchers

Forks

Packages

No packages published