#!/usr/bin/env bash
# Cron watchdog: restarts Mozart if the health endpoint is unreachable or not ready.
# Install: */5 * * * * /home/mozart/health-check.sh

if ! curl -sf --max-time 5 localhost:4141/health | grep -q '"ready":true'; then
  logger -t mozart-watchdog "Health check failed, restarting mozart.service"
  sudo systemctl restart mozart
fi
