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:
@@ -24,9 +24,19 @@ job "phaseflow-cron" {
|
|||||||
destination = "local/script.sh"
|
destination = "local/script.sh"
|
||||||
data = <<EOH
|
data = <<EOH
|
||||||
set -e
|
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" \
|
-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
|
EOH
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user