#!/bin/bash
# Remove the static Caddy route for this slot.
set -euo pipefail

: "${SLOT_RUN:?}"
: "${ORBIT_CADDY:?}"

rm -f -- "${SLOT_RUN}/Caddyfile"

if command -v caddy >/dev/null 2>&1; then
    caddy fmt --overwrite "$ORBIT_CADDY" || true
    caddy validate --config "$ORBIT_CADDY" || true
    caddy reload --config "$ORBIT_CADDY" || {
        echo "[down] warning: caddy reload failed; routes may linger" >&2
    }
fi
