Giter VIP home page Giter VIP logo

python-holdup's Introduction

Overview

docs Documentation Status
tests
package

A tool to wait for services and execute command. Useful for Docker containers that depend on slow to start services (like almost everything).

  • Free software: BSD 2-Clause License

Installlation

Currently holdup is only published to PyPI and hub.docker.com.

To install from PyPI:

pip install holdup

It has no dependencies except the optional PostgreSQL check support, which you'd install with:

pip install 'holdup[pg]'

You can also install the in-development version with:

pip install https://github.com/ionelmc/python-holdup/archive/master.zip

Alternate installation (Docker image)

Example:

docker run --rm ionelmc/holdup tcp://foobar:1234

Note that this will have some limitations:

  • executing the command is pretty pointless because holdup will run in its own container
  • you'll probably need extra network configuration to be able to access services
  • you won't be able to use docker run inside a container without exposing a docker daemon in said container

Usage

usage: holdup [-h] [-t SECONDS] [-T SECONDS] [-i SECONDS] [-n] service [service ...] [-- command [arg [arg ...]]]

Wait for services to be ready and optionally exec command.

positional arguments:
service
A service to wait for. Supported protocols: "tcp://host:port/", "path:///path/to/something", "unix:///path/to/domain.sock", "eval://expr", "pg://user:password@host:port/dbname" ("postgres" and "postgresql" also allowed), "http://urn", "https://urn", "https+insecure://urn" (status 200 expected for http*). Join protocols with a comma to make holdup exit at the first passing one, eg: "tcp://host:1,host:2" or "tcp://host:1,tcp://host:2" are equivalent and mean any that pass.
command
An optional command to exec.
optional arguments:
-h, --help show this help message and exit
-t SECONDS, --timeout SECONDS
 Time to wait for services to be ready. Default: 60.0
-T SECONDS, --check-timeout SECONDS
 Time to wait for a single check. Default: 1.0
-i SECONDS, --interval SECONDS
 How often to check. Default: 0.2
-v, --verbose Verbose mode.
--verbose-passwords
 Disable PostgreSQL/HTTP password masking.
-n, --no-abort Ignore failed services. This makes holdup return 0 exit code regardless of services actually responding.
--insecure Disable SSL Certificate verification for HTTPS services.
--version display the version of the holdup package and its location, then exit.

Example:

holdup tcp://foobar:1234 -- django-admin ...

Documentation

https://python-holdup.readthedocs.io/

Development

To run all the tests run:

tox

Note, to combine the coverage data from all the tox environments run:

Windows
set PYTEST_ADDOPTS=--cov-append
tox
Other
PYTEST_ADDOPTS=--cov-append tox

python-holdup's People

Contributors

blaise-io avatar ionelmc avatar mithun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

python-holdup's Issues

Add support for Acceptable HTTP status codes

I have a use case where the HTTP check returns a 401 since I'm not providing credentials.

I'd like to submit a PR to allow acceptable HTTP Status codes other than 200. Please let me know if you have preferences on how this should be implemented.

Add library support

I would like to exploit holdup, but from some python code, is there anyway to make it more like a library on top of the CLI?

Add support for Insecure HTTPS

The current HttpCheck against a https service defaults to requiring SSL Certificate Validation. In certain cases, we would like to perform a check against an IP address instead of a hostname (for e.g., holdup https://10.1.2.3). In this case the certificate validation will always fail due to a hostname mismatch.

Can we introduce an option to ignore certificate validation? For e.g., holdup --insecure https://10.1.2.3

I have been able to implement this change here. However, my change will break support for older pythons.

I'm willing to submit a PR if you can provide suggestions on how backwards compatibility can be maintained.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.