#!/bin/bash set -e echo '=== backend unit ===' systemctl cat tiktok-promo-backend.service | head -40 systemctl cat tiktok-promo-pocketbase.service 2>/dev/null | head -25 || true # Start Next + API (no live-router, no WP) systemctl enable --now tiktok-promo-pocketbase.service 2>/dev/null || true systemctl enable --now tiktok-promo-backend.service systemctl enable --now tiktok-promo-frontend.service systemctl restart tiktok-promo-frontend.service systemctl restart tiktok-promo-backend.service 2>/dev/null || true sleep 2 systemctl is-active tiktok-promo-frontend.service tiktok-promo-backend.service || true ss -lntp | grep -E ':3015|:8015' || true # Point Caddy default handle to Next :3015 (skip audience router) cp -a /etc/caddy/sites/nomadro.live.caddy /etc/caddy/sites/nomadro.live.caddy.bak.next_$(date +%Y%m%d_%H%M%S) python3 <<'PY' from pathlib import Path p = Path("/etc/caddy/sites/nomadro.live.caddy") text = p.read_text(encoding="utf-8") old = "reverse_proxy 127.0.0.1:4404" new = "reverse_proxy 127.0.0.1:3015" if old not in text: raise SystemExit("expected 4404 upstream not found") text = text.replace(old, new, 1) # update comment text = text.replace( "# TikTok Promo Next.js + FastAPI, plus English WordPress via audience router.", "# TikTok Promo Next.js + FastAPI (Next only; audience router / WP unused).", 1, ) p.write_text(text, encoding="utf-8") print("patched nomadro.live.caddy") print(p.read_text(encoding="utf-8")) PY caddy validate --config /etc/caddy/Caddyfile systemctl reload caddy sleep 1 systemctl is-active caddy curl -sS -m 10 -o /dev/null -w 'local3015=%{http_code}\n' http://127.0.0.1:3015/ || true curl -sS -m 10 -o /dev/null -w 'api=%{http_code}\n' http://127.0.0.1:8015/docs || true curl -sS -m 15 -o /dev/null -w 'public=%{http_code}\n' -L https://nomadro.live/ || true curl -sS -m 15 -o /dev/null -w 'www=%{http_code}\n' -L https://www.nomadro.live/ || true systemctl is-active nomadro-live-router.service || echo 'router=inactive (ok)' docker ps --format '{{.Names}} {{.Status}}' | grep -i 'live-wp\|wordpress' || true