douyinWEB/scripts/_deploy_yt_relay_start_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

49 lines
1.6 KiB
Python

# -*- coding: utf-8 -*-
"""Deploy YouTube relay Start fix — schedule bypass + real errors + logs."""
import os
import sys
import time
import paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
HOST = "107.173.30.245"
REPO = "/opt/douyinWEB"
LOCAL = r"C:/Users/admin/Desktop/douyinWEB"
FILES = [
"backend/app/youtube_relay.py",
"backend/app/youtube_relay_pipeline.py",
]
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect(HOST, 22, "root", "Xiao4669805", timeout=30, allow_agent=False, look_for_keys=False)
def run(cmd: str, timeout: int = 120) -> str:
_, o, e = c.exec_command(cmd, timeout=timeout)
return (o.read() + e.read()).decode("utf-8", "replace").strip()
ts = int(time.time())
print("[backup db]", run(f"cp -a {REPO}/backend/data/monitor.db /tmp/monitor.db.bak_yt_fix_{ts} && ls -lh /tmp/monitor.db.bak_yt_fix_{ts}"))
sftp = c.open_sftp()
for rel in FILES:
remote = f"{REPO}/{rel.replace(chr(92), '/')}"
local = f"{LOCAL}/{rel.replace(chr(92), '/')}"
print("[upload]", rel)
sftp.put(local, remote)
sftp.close()
print("[py_compile]", run(f"cd {REPO}/backend && ./venv/bin/python -m py_compile app/youtube_relay.py app/youtube_relay_pipeline.py && echo py_ok"))
print("[api restart]", run("systemctl restart douyinweb-api; sleep 6; systemctl is-active douyinweb-api"))
print("[health]", run("curl -s http://127.0.0.1:8014/api/health | head -c 200"))
print(
"[verify start_group ignore schedule]",
run(f"grep -n 'manual_hold\\|respect_schedule=False' {REPO}/backend/app/youtube_relay_pipeline.py | head -20"),
)
c.close()
print("DONE")