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

43 lines
1.3 KiB
Python

# -*- coding: utf-8 -*-
import sys
import time
import 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=300):
_, o, e = c.exec_command(cmd, timeout=timeout)
out = (o.read() + e.read()).decode("utf-8", "replace")
print(out[-3500:] if len(out) > 3500 else out)
return out
print("[git pull test1]")
run(
f"cd {REPO} && git fetch origin test1 && git checkout test1 && "
f"git pull --ff-only origin test1 && git log -1 --oneline"
)
print("[restart api]")
run("systemctl restart douyinweb-api")
time.sleep(12)
run("systemctl is-active douyinweb-api")
print("[npm build]")
run(f"cd {REPO}/frontend && npm run build >/tmp/yt_assign_build.log 2>&1; tail -15 /tmp/yt_assign_build.log", timeout=360)
print("[restart web]")
run("systemctl restart douyinweb-web")
time.sleep(5)
run("systemctl is-active douyinweb-api; systemctl is-active douyinweb-web")
run(
"curl -s -o /dev/null -w 'assign_api:%{http_code}\\n' "
"http://127.0.0.1:8014/api/youtube/assign/groups; "
"curl -s -o /dev/null -w 'youtube_page:%{http_code}\\n' http://127.0.0.1:4015/youtube"
)
c.close()
print("DONE")