douyinWEB/scripts/_deploy_nav_network.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

45 lines
1.7 KiB
Python

# -*- coding: utf-8 -*-
import sys, time
from pathlib import Path
import paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
ROOT = Path(__file__).resolve().parents[1]
PW = "4669805"
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect("107.173.30.245", 4014, "eric", PW, timeout=40, banner_timeout=80, allow_agent=False, look_for_keys=False)
sftp = c.open_sftp()
data = (ROOT / "frontend/src/lib/shellNav.ts").read_bytes().replace(b"\r\n", b"\n")
with sftp.file("/tmp/_up_shellNav.ts", "wb") as f:
f.write(data)
sftp.close()
_, o, e = c.exec_command(
f"echo '{PW}' | sudo -S -p '' bash -c '"
"install -m 644 /tmp/_up_shellNav.ts /opt/douyinWEB/frontend/src/lib/shellNav.ts; "
"systemctl stop douyinweb-web || true; "
"cd /opt/douyinWEB/frontend; "
"export DY_INTERNAL_API_URL=http://127.0.0.1:8014 DY_PUBLIC_BASE_URL=https://dy.nomadro.com; "
"npm run build >/tmp/fe-nav.log 2>&1; echo EXIT:$? >>/tmp/fe-nav.log; "
"systemctl start douyinweb-web'"
, timeout=600)
print((o.read()+e.read()).decode("utf-8","replace"), flush=True)
for i in range(40):
time.sleep(8)
_, o, e = c.exec_command("grep '^EXIT:' /tmp/fe-nav.log 2>/dev/null | tail -1")
st = (o.read()+e.read()).decode().strip()
print(f"fe[{i}] {st}", flush=True)
if "EXIT:0" in st:
break
if "EXIT:" in st:
_, o, e = c.exec_command("tail -30 /tmp/fe-nav.log")
print((o.read()+e.read()).decode("utf-8","replace"))
raise SystemExit(1)
else:
raise SystemExit("timeout")
_, o, e = c.exec_command("systemctl is-active douyinweb-web")
print((o.read()+e.read()).decode(), flush=True)
c.close()
print("DONE")