Skip to main content

Check health of static, long running applications using generated files.

Project description

file-healthchecker

Use this application to monitor your long running "non-web" application's health check.

Build Status

Installation

pip

pip install file-healthchecker

Use Case

Lets say we have a service which needs to perform some action every x-duration. In python-world we would simply run it inside a while loop and invoke it every x-minutes.

Now define an environment var ENV_HEALTH_CHECK_FILE which will represent a file creation in case the app is healthy. for e.g. export ENV_HEALTH_CHECK_FILE=/tmp/myapp.is.healthy

This following snippet will perform following tasks:

  • Every invocation of my_application will first remove a health-check file.
  • Run the application
  • NOTE: Raise an exception in case the application is failing. Handle it outside, as show in the given example.
  • If no exception is raised, the decorator will create a file defined by the env-var ENV_HEALTH_CHECK_FILE
from file_healthchecker import decorator_success
import time

@decorator_success
def my_application():
    ... doing lots of work
    ... more work
    # in case of failure, raise exception
    return True

if __name__ == "__main__":
    while True:
        try:
            my_application()
        except Exception:
            pass
        time.sleep(10)

With the installation another cmd-app also gets installed - checkhealth.

How to check application's health?

  • One can simply run ENV_HEALTH_CHECK_FILE=/tmp/myapp.is.healthy checkhealth at regular intervals or
  • pass this command to orchestrators like Nomad, Kubernetes, etc. as a part of their health-check commands.

Current Stable Version

0.1.0

Development Installation

  • Clone the project.
  • Now install the application in editable mode and you are ready to start development
$ pip install -e .

Test

To run the tests:

make test

License

MIT

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

file-healthchecker-0.1.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

file_healthchecker-0.1.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file file-healthchecker-0.1.0.tar.gz.

File metadata

  • Download URL: file-healthchecker-0.1.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.1

File hashes

Hashes for file-healthchecker-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7ebe8fdd60cb34dfadc55cb6474d42b6b1e88d61d9672384216548a95c42d76d
MD5 b059be01bc370bdfcfa418580699a474
BLAKE2b-256 7e7e89865c314295aa9aaf28405fadd5c3b4a683222762f8919194d1389e2e01

See more details on using hashes here.

File details

Details for the file file_healthchecker-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: file_healthchecker-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.1

File hashes

Hashes for file_healthchecker-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1848aab7e32f8be42b65500703a005c944456c2de26e7886ddfeddbb5eae7306
MD5 12e6181978c41c10a03653a4d7e2e066
BLAKE2b-256 29941c0bd549b56e139d162cc4291c1caeaed910ecf06bf687291c0537ead120

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page