Check health of static, long running applications using generated files.
Use this application to monitor your long running "non-web" application's health check.
pip install file-healthchecker
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.
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
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 -
How to check application's health?
- One can simply run
ENV_HEALTH_CHECK_FILE=/tmp/myapp.is.healthy checkhealthat regular intervals or
- pass this command to orchestrators like
Kubernetes, etc. as a part of their health-check commands.
Current Stable Version
- Clone the project.
- Now install the application in editable mode and you are ready to start development
$ pip install -e .
To run the tests:
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size file_healthchecker-0.1.1-py3-none-any.whl (5.1 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size file-healthchecker-0.1.1.tar.gz (4.1 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for file_healthchecker-0.1.1-py3-none-any.whl