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

42 lines
1.4 KiB
Python

# -*- coding: utf-8 -*-
import paramiko
import sys
from pathlib import Path
if hasattr(sys.stdout, "reconfigure"):
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
ROOT = Path(__file__).resolve().parents[1]
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect("108.174.50.68", 22, "root", "Xiao4669805", timeout=45, allow_agent=False, look_for_keys=False)
sftp = c.open_sftp()
for local, remote in [
(ROOT / "backend/app/youtube_manage.py", "/opt/douyinWEB/backend/app/youtube_manage.py"),
(ROOT / "scripts/_refresh_yt_avatars.py", "/tmp/_refresh_yt_avatars.py"),
]:
data = local.read_bytes().replace(b"\r\n", b"\n")
with sftp.file(remote, "wb") as f:
f.write(data)
print("up", remote)
sftp.close()
def run(cmd, timeout=120):
_, o, e = c.exec_command(cmd, timeout=timeout)
print(o.read().decode("utf-8", "replace"))
err = e.read().decode("utf-8", "replace")
if err.strip():
print("ERR", err[:1200])
run("systemctl restart douyinweb-api; sleep 3; systemctl is-active douyinweb-api")
run("cd /opt/douyinWEB/backend && PYTHONPATH=. .venv/bin/python /tmp/_refresh_yt_avatars.py", timeout=180)
# verify one avatar URL
run(
"cd /opt/douyinWEB/backend && PYTHONPATH=. .venv/bin/python -c \""
"from app import youtube_manage;"
"m=youtube_manage.list_yt_profile_caches();"
"[print(v.get('title'), v.get('thumb_url')) for v in m.values()]"
"\""
)
c.close()