fix wp-mirror-sync: explicit HTTP 200/301 health check
This commit is contained in:
parent
e41bb43024
commit
a6b3c450f8
1 changed files with 10 additions and 5 deletions
|
|
@ -20,6 +20,13 @@ log() {
|
|||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*" | tee -a "$LOG"
|
||||
}
|
||||
|
||||
ct101_http_ok() {
|
||||
local code
|
||||
code="$(ssh -o BatchMode=yes -o ConnectTimeout=15 "$HETZNER_HOST" \
|
||||
"pct exec ${HETZNER_CT} -- curl -sS -o /dev/null -w '%{http_code}' --max-time 15 http://127.0.0.1/" 2>/dev/null || echo 000)"
|
||||
[[ "$code" == "200" || "$code" == "301" ]]
|
||||
}
|
||||
|
||||
tar_sync_files() {
|
||||
rm -rf "${STAGING}/wpfiles"
|
||||
mkdir -p "${STAGING}/wpfiles"
|
||||
|
|
@ -50,9 +57,8 @@ fi
|
|||
mkdir -p "$STAGING" "$(dirname "$LOG")"
|
||||
|
||||
log "Checking CT101 health..."
|
||||
if ! ssh -o BatchMode=yes -o ConnectTimeout=15 "$HETZNER_HOST" \
|
||||
"pct exec ${HETZNER_CT} -- curl -sf -o /dev/null --max-time 15 http://127.0.0.1/"; then
|
||||
log "ABORT: CT101 does not respond on http://127.0.0.1/"
|
||||
if ! ct101_http_ok; then
|
||||
log "ABORT: CT101 does not respond on http://127.0.0.1/ (expected HTTP 200/301)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
@ -109,8 +115,7 @@ LAST="$(pct exec "$MIRROR_CT" -- docker exec wordpress-mysql mysql -u"$MYSQL_USE
|
|||
"SELECT MAX(post_date) FROM wp_posts WHERE post_type='post';" "$MYSQL_DB" 2>/dev/null)"
|
||||
log "Mirror verified: ${POSTS} published posts, latest ${LAST}"
|
||||
|
||||
if ! ssh -o BatchMode=yes -o ConnectTimeout=15 "$HETZNER_HOST" \
|
||||
"pct exec ${HETZNER_CT} -- curl -sf -o /dev/null --max-time 15 http://127.0.0.1/"; then
|
||||
if ! ct101_http_ok; then
|
||||
log "WARN: CT101 health check failed AFTER sync — investigate immediately"
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue