#!/bin/bash
# Dealspace Healthcheck Script
# Runs every 5 minutes via cron, alerts via ntfy if down

HEALTH=$(curl -sf --max-time 5 http://localhost:8080/health | python3 -c "import sys,json; print(json.load(sys.stdin)['status'])" 2>/dev/null)

if [ "$HEALTH" != "ok" ]; then
    curl -s https://ntfy.inou.com/inou-alerts \
        -H "Authorization: Bearer tk_k120jegay3lugeqbr9fmpuxdqmzx5" \
        -H "Title: Dealspace DOWN" \
        -H "Priority: urgent" \
        -H "Tags: warning" \
        -d "Dealspace health check failed on Shannon (82.24.174.112)"
fi
