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

53 lines
1.4 KiB
Python

import paramiko
import sys
import time
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
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: str, t: int = 120) -> str:
_, o, e = c.exec_command(cmd, timeout=t)
return (o.read() + e.read()).decode("utf-8", "replace")
print("=== PULL ===")
print(run("cd /opt/douyinWEB && GIT_TERMINAL_PROMPT=0 git pull origin dev && git log --oneline -2", t=180))
print("=== NGINX WS ===")
print(
run(
"grep -RIn 'proxy_set_header Upgrade\\|8014\\|dylive' /etc/nginx/ 2>/dev/null | head -40"
)
)
# Ensure API location has websocket headers if missing
print("=== PATCH CHECK ===")
print(
run(
"ls /etc/nginx/sites-enabled/ 2>/dev/null; ls /etc/nginx/conf.d/ 2>/dev/null; "
"grep -l dylive /etc/nginx/sites-enabled/* /etc/nginx/conf.d/* 2>/dev/null | head -5"
)
)
print("=== RESTART API ===")
run("systemctl restart douyinweb-api")
time.sleep(6)
print(run("systemctl is-active douyinweb-api"))
print(run("curl -sS http://127.0.0.1:8014/api/health"))
print(run("test -f /opt/douyinWEB/backend/app/x2_ws.py && echo HAS_X2_WS"))
print(run("cd /opt/douyinWEB && git log --oneline -1"))
print("DEPLOY_DONE")
c.close()