# -*- coding: utf-8 -*- """Deploy PWA install UX fix (frontend build only).""" import sys, time, paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") REPO = "/opt/douyinWEB" c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect("107.173.30.245", 22, "root", "Xiao4669805", timeout=30, allow_agent=False, look_for_keys=False) def run(cmd, timeout=600): _, o, e = c.exec_command(cmd, timeout=timeout) return (o.read() + e.read()).decode("utf-8", "replace").strip() dirty = run(f"cd {REPO} && git diff --name-only -- frontend/src/components/PwaInstallBanner.tsx frontend/public/manifest.webmanifest frontend/public/sw.js") if dirty.strip(): print("[stash]", run(f"cd {REPO} && git stash push -m auto-before-pwa -- frontend/src/components/PwaInstallBanner.tsx frontend/public/manifest.webmanifest frontend/public/sw.js")) print("[pull]", run(f"cd {REPO} && git pull --ff-only origin test1 && git log --oneline -1")) print("[build]", run(f"cd {REPO}/frontend && npm run build 2>&1 | tail -n 30", timeout=600)) run("systemctl restart douyinweb-web || true") time.sleep(2) print("[svc]", run("systemctl is-active douyinweb-web douyinweb-api; curl -sS -m 10 -o /dev/null -w '%{http_code}' https://dylive.nomadro.com/manifest.webmanifest")) print(run("curl -sS -m 10 https://dylive.nomadro.com/manifest.webmanifest | head -c 200")) c.close() print("DONE")