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

41 lines
1.6 KiB
Python

import paramiko
import time
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect("107.173.30.245", 22, "root", "Xiao4669805", timeout=15, allow_agent=False, look_for_keys=False)
def run(cmd, timeout=30):
_, out, err = c.exec_command(cmd, timeout=timeout)
return (out.read() + err.read()).decode("utf-8", "replace").strip()
print("=== services ===")
print("api:", run("systemctl is-active douyinweb-api"))
print("web:", run("systemctl is-active douyinweb-web"))
print("\n=== api status ===")
print(run("systemctl status douyinweb-api --no-pager -l 2>&1 | tail -20").encode("ascii", "replace").decode())
print("\n=== port 8014 ===")
print(run("ss -tlnp | grep 8014 || netstat -tlnp | grep 8014"))
print("\n=== curl local ===")
print(run("curl -s -o /dev/null -w 'HTTP:%{http_code}' http://127.0.0.1:8014/api/tiktok/oauth/callback/tiktokSac63LUYsqRR1brRHZ2v2hw9x0RjXR9L.txt"))
print("\n=== verify file exists ===")
print(run("ls -la /opt/douyinWEB/backend/tiktok_verify/"))
print("\n=== nginx error (last) ===")
print(run("tail -5 /var/log/nginx/error.log 2>/dev/null || tail -5 /var/log/nginx/dylive.error.log 2>/dev/null").encode("ascii", "replace").decode()[:800])
# fix: kill stuck api and restart
print("\n=== restarting api ===")
c.exec_command("systemctl kill -s SIGKILL douyinweb-api 2>/dev/null", timeout=5)
time.sleep(2)
c.exec_command("systemctl start douyinweb-api", timeout=5)
time.sleep(12)
print("api after:", run("systemctl is-active douyinweb-api"))
print("curl after:", run("curl -s http://127.0.0.1:8014/api/tiktok/oauth/callback/tiktokSac63LUYsqRR1brRHZ2v2hw9x0RjXR9L.txt"))
c.close()