Skip to content

Commit

Permalink
Add README and LICENSE
Browse files Browse the repository at this point in the history
  • Loading branch information
mfrister committed Aug 6, 2015
1 parent fd2f972 commit b6ee3f3
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015 Cash Payment Solutions GmbH

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# waitforservices

A small utility waiting for services linked to a Docker container being ready.

Without configuration, it finds all TCP services linked to a Docker container via their [environment variables](http://docs.docker.com/userguide/dockerlinks/#environment-variables) and concurrently and repeatedly tries to open a TCP connection to all of them.

When all connections are successful, it returns. If one or more services aren't ready within 60 seconds, it aborts and exits with status 1.

`waitforservices` also supports waiting for an HTTP request to `/` to return a response.

## Installation

First, install the utility into your image by adding this to your Dockerfile:

RUN curl -LsS https://github.com/Barzahlen/waitforservices/releases/download/0.1/waitforservices \
> /usr/local/bin/waitforservices && \
chmod +x /usr/local/bin/waitforservices

There's also a Makefile in this repository if you want to build the binary yourself.

Then, during container startup, you can use the `waitforservices` command to wait for all services being ready.

## Usage

$ ./waitforservice -help
Usage of ./waitforservices:
-httpport=0: wait for an http request if target port is given port
-ignoreport=0: don't wait for services on this port to be up
-timeout=60: time to wait for all services to be up (seconds)

Attempt to connect to all TCP services linked to a Docker container (found
via their env vars) and wait for them to accept a TCP connection.

When an <httpport> is specified, for services running on <httpport>, after
a successful TCP connect, do an HTTP request and wait until it's done. This
is useful for slow-starting services that only start up when they receive
their first request.

When timeout is over and TCP connect or HTTP request were unsucecssful, exit
with status 1.

## License

waitforservices is licensed under [MIT](LICENSE).

0 comments on commit b6ee3f3

Please sign in to comment.