Subscribes to the SSE stream that our Spinitron API proxy generates (to indicate that a new Spin was logged). When the message is received, query the latest spin and package it into a message that is sent to a RabbitMQ exchange for downstream consumption (e.g. an RDS encoder).
If the SSE stream from the proxy is interrupted, the watchdog will attempt to reconnect. If reconnections fail, it switches to polling mode. In both SSE-triggered fetches and polling mode, if the API proxy endpoint for fetching spins is unreachable, the watchdog will fall back to querying the primary Spinitron API directly using an API key. It polls for new spins every 3 seconds (by default) while periodically checking for the proxy's SSE stream to come back online. Once the proxy's SSE stream is back online, it switches back to listening to the SSE stream.
This project uses uv for dependency management.
Ensure Make is installed on your system.
- Clone the repository
- Copy
.env.sampleto.envand fill in the values. This includes:API_BASE_URLfor the Spinitron proxy.SPINITRON_API_URLfor the primary Spinitron API (e.g.,https://spinitron.com/api/).SPINITRON_API_KEYfor the primary Spinitron API.- RabbitMQ connection details.
- Change values in the Makefile as needed (enter a HOST_DIR)
- Run
make- Alternatively, run
DOCKER_TOOL=podman makeif you are using Podman
- Alternatively, run
- Install uv:
curl -LsSf https://astral.sh/uv/install.sh | sh - Clone the repository
- Copy
.env.sampleas.envand fill in values - Install dependencies:
uv sync - Run the application:
uv run python watchdog.py