A CLI utility for blocking until a service is listening
Project description
I needed a way to block my app from starting until the database service was running and accepting connections. This was particularly a problem when using Docker and docker-compose. You can run this utility as part of a run-dev.sh or run-tests.sh script and it will block for 15 seconds (configurable) until it can connect to the hostname and port as specified in your connection URL (gleaned from DATABASE_URL environment variable by default).
Installation
$ pip install urlwait
Usage
$ urlwait --help Usage: $ urlwait [SERVICE URL] [TIMEOUT] SERVICE URL is a connection url, e.g. a typical value for $DATABASE_URL. TIMEOUT is a number of seconds to try to connect to the host and port specified in the SERVICE URL. These values may also be specified in environment variables, but command line args take precedence: URLWAIT_VARNAME: the env var name containing the URL to check. Default DATABASE_URL. URLWAIT_TIMEOUT: the number of seconds to wait. Default 15. Returns a 0 status if the connection completed successfully before the timeout, or 1 if not. It is designed for use with Docker or other dev or testing environments where the connected services and the app are started simultaneously, but one should wait for the other. Examples: The following are equivalent: $ urlwait redis://localhost:6379/0 20 $ urlwait $CACHE_URL 20 $ URLWAIT_VARNAME=CACHE_URL URLWAIT_TIMEOUT=20 urlwait
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
urlwait-0.1.tar.gz
(3.5 kB
view details)
Built Distribution
File details
Details for the file urlwait-0.1.tar.gz
.
File metadata
- Download URL: urlwait-0.1.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 091f34c77da3aed4a3d56403c59c5f5cf2486b36169fb5af61aa26a2306282b4 |
|
MD5 | 93c7a8ddb5636ff896235d999300cd30 |
|
BLAKE2b-256 | 89a3baba11ac68a86f933e0bf55f4f44926a3374f06a303f41704690bcc219d6 |
File details
Details for the file urlwait-0.1-py2.py3-none-any.whl
.
File metadata
- Download URL: urlwait-0.1-py2.py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87ca9f7b7f787716cdeecf04d5845e6877ebd8980adc6f75ab743281acf1f1f3 |
|
MD5 | 23e42824ef732e3203ff02bb7e2cddd5 |
|
BLAKE2b-256 | f46e66e2c459ffb5f56f1c951d3534c0a4788ba9d336fa76f0d9fefda8ad71f6 |