Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Script to test and wait on the availability of a TCP host and port. Forked from vishnubob/wait-for-it for Alpine Linux on Docker.

License

NotificationsYou must be signed in to change notification settings

ucalgary/wait-for-it

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

This is a fork ofvishnubob/wait-for-it to supportAlpine based Docker images. It was originally modified for use in RMS project images at the University of Calgary. Note that this fork of the script has more limited support for arguments than the original script.

wait-for-it.sh is a script that will wait on the availability of a host and TCP port. It is useful for synchronizing the spin-up of interdependent services, such as linked docker containers. It depends on nc to determine availability.

Usage

wait-for-it.sh host:port [-s] [-t timeout] [-- command args]-h HOST                     Host or IP under test-p PORT                     TCP port under test-s                          Only execute subcommand if the test succeeds-q                          Don't output any status messages-t TIMEOUT                  Timeout in seconds, zero for no timeout-- COMMAND ARGS             Execute command with args after the test finishes

Examples

For example, let's test to see if we can access port 80 onwww.google.com, and if it is available, echo the messagegoogle is up.

$ ./wait-for-it.sh -h www.google.com -p 80 -- echo "google is up"wait-for-it.sh: waiting 15 seconds for www.google.com:80wait-for-it.sh: www.google.com:80 is available after 0 secondsgoogle is up

You can set your own timeout with the-t option. Setting the timeout value to 0 will disable the timeout:

$ ./wait-for-it.sh -t 0 -h www.google.com -p 80 -- echo "google is up"wait-for-it.sh: waiting for www.google.com:80 without a timeoutwait-for-it.sh: www.google.com:80 is available after 0 secondsgoogle is up

The subcommand will be executed regardless if the service is up or not. If you wish to execute the subcommand only if the service is up, add the-s argument. In this example, we will test port 81 onwww.google.com which will fail:

$ ./wait-for-it.sh -h www.google.com -p 81 -t 1 -s -- echo "google is up"wait-for-it.sh: waiting 1 seconds for www.google.com:81wait-for-it.sh: timeout occurred after waiting 1 seconds for www.google.com:81wait-for-it.sh: strict mode, refusing to execute subprocess

If you don't want to execute a subcommand, leave off the-- argument. This way, you can test the exit condition ofwait-for-it.sh in your own scripts, and determine how to proceed:

$ ./wait-for-it.sh -h www.google.com -p 80wait-for-it.sh: waiting 15 seconds for www.google.com:80wait-for-it.sh: www.google.com:80 is available after 0 seconds$ echo $?0$ ./wait-for-it.sh -h www.google.com -p 81wait-for-it.sh: waiting 15 seconds for www.google.com:81wait-for-it.sh: timeout occurred after waiting 15 seconds for www.google.com:81$ echo $?124

About

Script to test and wait on the availability of a TCP host and port. Forked from vishnubob/wait-for-it for Alpine Linux on Docker.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell100.0%

[8]ページ先頭

©2009-2025 Movatter.jp