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

94 lines
2.6 KiB
Python

# -*- coding: utf-8 -*-
"""Deploy AuthorizedChannelPicker UI to physical guest and rebuild Next."""
from __future__ import annotations
import sys
import time
from pathlib import Path
import paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
ROOT = Path(__file__).resolve().parents[1]
LOCAL = ROOT / "frontend" / "src" / "components" / "YtAssignPanel.tsx"
REMOTE = "/opt/douyinWEB/frontend/src/components/YtAssignPanel.tsx"
PASS = "4669805"
def ssh():
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect(
"107.173.30.245",
4014,
"eric",
PASS,
timeout=60,
banner_timeout=120,
allow_agent=False,
look_for_keys=False,
)
return c
def run(c, cmd, timeout=600):
_, o, e = c.exec_command(cmd, timeout=timeout)
out = (o.read() + e.read()).decode("utf-8", "replace")
print(out[-5000:] if len(out) > 5000 else out, flush=True)
return out
def main():
if not LOCAL.is_file():
raise SystemExit(f"missing {LOCAL}")
text = LOCAL.read_text(encoding="utf-8")
if "AuthorizedChannelPicker" not in text:
raise SystemExit("local file missing AuthorizedChannelPicker")
c = ssh()
# stage to /tmp then sudo install (remote owned by root)
sftp = c.open_sftp()
with sftp.file("/tmp/YtAssignPanel.tsx", "w") as f:
f.write(text)
sftp.close()
print("uploaded /tmp/YtAssignPanel.tsx", flush=True)
run(
c,
f"echo '{PASS}' | sudo -S -p '' bash -lc '"
f"cp -a {REMOTE} {REMOTE}.bak-picker-$(date +%s); "
f"install -m 644 /tmp/YtAssignPanel.tsx {REMOTE}; "
f"grep -n AuthorizedChannelPicker {REMOTE} | head -3"
f"'",
timeout=60,
)
print("=== npm build ===", flush=True)
run(
c,
f"echo '{PASS}' | sudo -S -p '' bash -lc '"
"cd /opt/douyinWEB/frontend && npm run build"
"'",
timeout=600,
)
print("=== restart web ===", flush=True)
run(
c,
f"echo '{PASS}' | sudo -S -p '' bash -lc '"
"systemctl restart douyinweb-web; sleep 3; "
"systemctl is-active douyinweb-web; "
"grep -R AuthorizedChannelPicker /opt/douyinWEB/frontend/.next/server 2>/dev/null | head -2 || "
"grep -R AuthorizedChannelPicker /opt/douyinWEB/frontend/.next/static 2>/dev/null | head -2 || "
"echo 'search_done'"
"'",
timeout=90,
)
c.close()
print("DONE — hard refresh https://dy.nomadro.com/youtube?live=1", flush=True)
if __name__ == "__main__":
main()