Skip to content
Snippets Groups Projects
Commit 4f55896a authored by Marcel Huber's avatar Marcel Huber
Browse files

adjusted readme, setup ci

parent 49691564
No related branches found
No related tags found
No related merge requests found
Pipeline #260953 canceled
# This file is a template, and might need editing before it works on your project.
# Official language image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/python/tags/
image: python:2-slim
# Change pip's cache directory to be inside the project directory since we can
# only cache local items.
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
# Pip's cache doesn't store the python packages
# https://pip.pypa.io/en/stable/reference/pip_install/#caching
#
# If you want to also cache the installed packages, you have to install
# them in a virtualenv and cache it as well.
cache:
paths:
- .cache/pip
- venv/
before_script:
- python -V # Print out python version for debugging
- pip install virtualenv
- virtualenv venv
- source venv/bin/activate
test:
script:
- python test/wait-for-it.py
language: python
python:
- "2.7"
script:
- python test/wait-for-it.py
= Changelog
== feature/PureShellifyScript
* fixed busybox >=1.30 behavior with timeout command (4969156)
* replaced bash specifics with shell compatible commands (9bd77e1)
* Merge branch 'fwoelffel-master' (54d1f0b)
* Merge branch 'master' of https://github.com/fwoelffel/wait-for-it into fwoelffel-master (9995b72)
* Merge pull request #60 from aviau/patch-1 (4dd67a6)
* Merge branch 'scop-deps' (4d0a46b)
* README: community section + mention Debian package (e34c502)
* Fall back to readlink -f if realpath is not available or fails (019f3bb)
* Use parameter expansion instead of basename (5fe30e7)
* Use type -p instead of which (f9a0dc4)
* Add a WAITFORIT_ prefix in front of all variables (410d77e)
* Merge pull request #40 from szczad/master (db04971)
* fix: preserve quotation when passing arguments to command. (8ed92e8)
* Merge pull request #6 from iturgeon/master (8b4051d)
* Merge pull request #32 from douglas-gibbons/master (a2acebe)
* Fixes to test script for flake8 (8ed81e3)
* Update to README.md (b638c19)
* Tidy up of vars in tests (f9b79b2)
* Modified error output for 'ls' command to cope with different test environments (1374528)
* Added some real tests (4fd1b45)
* Start of test framework (13c00e3)
* Start of test framework (7f645ce)
* Update README.md (ac37241)
* Update README.md (409b4a7)
* Update README.md (209be48)
* readme update (e686775)
* Update README.md (e1f115e)
* Update README.md (1f3eb2c)
* Update README.md (11afe7b)
* Adds support for distros that use busybox like Alpine (8f52a81)
* Merge pull request #4 from Silex/patch-1 (a454892)
* Fix invalid use of return value (55c54a5)
* license added (20c6094)
* more small doc fixes (4e94d7d)
* doc fixes (bf194c8)
* doc fixes (a150deb)
* small fixes (41deb2d)
* initial commit (e559a8e)
## wait-for-it
= wait-for-it
`wait-for-it.sh` is a pure bash 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. Since it is a pure bash script, it does not have any external dependencies.
`wait-for-it.sh` is a pure sh 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.
Since it is a pure sh script, it does not have any external dependencies.
## Usage
== Usage
```
[source, sh]
----
wait-for-it.sh host:port [-s] [-t timeout] [-- command args]
-h HOST | --host=HOST Host or IP under test
-p PORT | --port=PORT TCP port under test
......@@ -14,40 +17,48 @@ wait-for-it.sh host:port [-s] [-t timeout] [-- command args]
-t TIMEOUT | --timeout=TIMEOUT
Timeout in seconds, zero for no timeout
-- COMMAND ARGS Execute command with args after the test finishes
```
----
## Examples
== Examples
For example, let's test to see if we can access port 80 on www.google.com, and if it is available, echo the message `google is up`.
```
[source, sh]
----
$ ./wait-for-it.sh www.google.com:80 -- echo "google is up"
wait-for-it.sh: waiting 15 seconds for www.google.com:80
wait-for-it.sh: www.google.com:80 is available after 0 seconds
google is up
```
----
You can set your own timeout with the `-t` or `--timeout=` option. Setting the timeout value to 0 will disable the timeout:
You can set your own timeout with the `-t` or `--timeout=` option.
Setting the timeout value to 0 will disable the timeout:
```
[source, sh]
----
$ ./wait-for-it.sh -t 0 www.google.com:80 -- echo "google is up"
wait-for-it.sh: waiting for www.google.com:80 without a timeout
wait-for-it.sh: www.google.com:80 is available after 0 seconds
google 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 `--strict` argument. In this example, we will test port 81 on www.google.com which will fail:
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 `--strict` argument.
In this example, we will test port 81 on www.google.com which will fail:
```
[source, sh]
----
$ ./wait-for-it.sh www.google.com:81 --timeout=1 --strict -- echo "google is up"
wait-for-it.sh: waiting 1 seconds for www.google.com:81
wait-for-it.sh: timeout occurred after waiting 1 seconds for www.google.com:81
wait-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 of `wait-for-it.sh` in your own scripts, and determine how to proceed:
If you don't want to execute a subcommand, leave off the `--` argument.
This way, you can test the exit condition of `wait-for-it.sh` in your own scripts, and determine how to proceed:
```
[source, sh]
----
$ ./wait-for-it.sh www.google.com:80
wait-for-it.sh: waiting 15 seconds for www.google.com:80
wait-for-it.sh: www.google.com:80 is available after 0 seconds
......@@ -58,8 +69,8 @@ wait-for-it.sh: waiting 15 seconds for www.google.com:81
wait-for-it.sh: timeout occurred after waiting 15 seconds for www.google.com:81
$ echo $?
124
```
----
## Community
== Community
*Debian*: There is a [Debian package](https://tracker.debian.org/pkg/wait-for-it).
_Debian_: There is a https://tracker.debian.org/pkg/wait-for-it[Debian package].
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment