Skip to content

🦫 Wait for service(s) to be available before executing a command.

Notifications You must be signed in to change notification settings

hartwork/go-wait-for-it

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Actions: Build and test Test coverage

go-wait-for-it

About

wait-for-it is a lookalike of (the perfectly fine) Python wait-for-it written in Go 1.20+.

It supports waiting for multiple services concurrently by default, and has a test coverage of 100%. If you do find bugs, please file a report. Thank you!

Install and run

$ go install github.com/hartwork/go-wait-for-it/v2/cmd/wait-for-it@latest
$ export PATH="${PATH}:$(go env GOPATH)/bin"
$ wait-for-it --version
wait-for-it 2.0.0

Build and run

$ ( cd v2 && go build ./cmd/wait-for-it )
$ ./v2/wait-for-it --version
wait-for-it 2.0.0

Examples

$ wait-for-it -t 2 -s :631 -s [::1]:631 -s localhost:631 -s 127.0.0.1:631 -- echo 'CUPS is very available'
[*] Trying to connect to :631...
[*] Trying to connect to [::1]:631...
[*] Trying to connect to localhost:631...
[*] Trying to connect to 127.0.0.1:631...
[+] Connected to [::1]:631 after 5.458196ms.
[+] Connected to 127.0.0.1:631 after 201.653µs.
[+] Connected to :631 after 158.548µs.
[+] Connected to localhost:631 after 381.536µs.
[*] Running command: echo CUPS is very available
CUPS is very available
[+] Command succeeded.

Usage

$ wait-for-it --help
Wait for service(s) to be available before executing a command.

Usage:
  wait-for-it [flags] [-s|--service [HOST]:PORT]... [--] [COMMAND [ARG ..]]

Flags:
  -h, --help              help for wait-for-it
  -q, --quiet             do not output any status messages
  -s, --service strings   services to test (format '[HOST]:PORT')
  -t, --timeout uint      timeout in seconds, 0 for no timeout (default 15)
  -v, --version           version for wait-for-it

wait-for-it is software libre, licensed under the AGPL v3 or later license.
Please report bugs at https://github.com/hartwork/go-wait-for-it/issues.  Thank you!

Alternatives

Go

Python

Rust

Shell