Improve phaseflow-cron logging on failure

Show the API response body in logs instead of silently failing
with curl exit code 22.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-15 07:40:28 +00:00
parent 8d97d09b07
commit 526888cd26

View File

@@ -24,9 +24,19 @@ job "phaseflow-cron" {
destination = "local/script.sh"
data = <<EOH
set -e
/run/current-system/sw/bin/curl -s -f -X POST \
RESPONSE=$(/run/current-system/sw/bin/curl -s -w "\n%%{http_code}" -X POST \
-H "Authorization: Bearer $CRON_SECRET" \
https://phaseflow.v.paler.net/api/cron/garmin-sync
https://phaseflow.v.paler.net/api/cron/garmin-sync)
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
BODY=$(echo "$RESPONSE" | sed '$d')
echo "$BODY"
if [ "$HTTP_CODE" -ge 400 ]; then
echo "HTTP error: $HTTP_CODE" >&2
exit 1
fi
EOH
}