douyinWEB/scripts/_deploy_pwa_fix2.py
eric d409e416da Ship physical dual-edge stack, Studio CDP live metrics, and ops tooling.
Capture Neko/WG/network hubs, Studio viewer charts, physical deploy docs, and one-shot scripts so VPS vs physical can be toggled later without losing WIP.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-04 22:42:40 -05:00

38 lines
1.5 KiB
Python

# -*- coding: utf-8 -*-
"""Force-sync PWA files and rebuild frontend."""
import sys, time, paramiko
from pathlib import Path
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
ROOT = Path(r"c:\Users\admin\Desktop\douyinWEB")
REPO = "/opt/douyinWEB"
files = [
"frontend/src/components/PwaInstallBanner.tsx",
"frontend/public/manifest.webmanifest",
"frontend/public/sw.js",
]
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)
sftp = c.open_sftp()
for rel in files:
lp = ROOT / rel
rp = f"{REPO}/{rel}"
sftp.put(str(lp), rp)
print("put", rel)
sftp.close()
def run(cmd, timeout=600):
_, o, e = c.exec_command(cmd, timeout=timeout)
return (o.read() + e.read()).decode("utf-8", "replace").strip()
# also stash dirty ext and pull to sync commit
print("[stash ext]", run(f"cd {REPO} && git stash push -m auto-ext-dirty -- extensions/dylive-helper/manifest.json extensions/dylive-helper/package.json || true"))
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 20", timeout=600))
run("systemctl restart douyinweb-web")
time.sleep(2)
print(run("curl -sS -m 10 https://dylive.nomadro.com/manifest.webmanifest"))
print(run("curl -sS -m 10 https://dylive.nomadro.com/sw.js | head -n 5"))
c.close()
print("DONE")