Go to file
2024-11-15 11:31:43 -08:00
.gitignore
Dockerfile
healthcheck.py
README.md Add instructions for running Healthcheck script to README 2024-11-15 11:31:43 -08:00
requirements.txt

Healthcheck

A healthcheck script that pings services, and if they are unreachable, restarts any associated Docker containers.

This script was created in order to restart Cloudflare Tunnel containers that would become unresponsive and never recover without manually restarting them.

Tunnels becoming unresponsive happens regularly due to intermittent internet connectivity.

The containers are responsible for hosting the tunnels associated with the following services:

Running the Healthcheck Script

Prior to running the script, you must set the following environment variables (example values provided):

CHECK_INTERVAL=60
MOSHFERATU_DEV_URL=https://moshferatu.dev
MOSHFERATU_DEV_CONTAINER=moshferatu-dev-tunnel
MOSHINGTON_URL=https://moshington.com
MOSHINGTON_CONTAINER=moshington-tunnel

The healthcheck depends on python-dotenv, so you can create a .env file and place the variables in there.

Docker Container

The script can be run in a Docker container of its own.

The necessary Dockerfile is provided here.

Just build and run the container like any other, while making sure to set the necessary environment variables as mentioned above.

Standalone Script

Make sure you have the dependencies listed in requirements.txt installed in addition to Docker.

Then, run the following command:

python ./healthcheck.py

Again, make sure to set the necessary environment variables before running the script.