douyinWEB/scripts/_diag_dy_images.py
2026-09-13 22:10:49 -05:00

91 lines
3.5 KiB
Python

#!/usr/bin/env python3
"""Read-only: why images missing on dy.nomadro.com. No config changes."""
from __future__ import annotations
import re
import sys
import time
import httpx
import paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace", line_buffering=True)
HOST = "107.173.30.245"
def connect(port=22, user="root", pw="Xiao4669805"):
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect(HOST, port, user, pw, timeout=25, banner_timeout=40, allow_agent=False, look_for_keys=False)
print(f"connected :{port}", flush=True)
return c
def run(c, cmd, t=50):
print(f"\n$ {cmd[:220]}", flush=True)
_i, o, e = c.exec_command(cmd, timeout=t)
while not o.channel.exit_status_ready():
if o.channel.recv_ready():
sys.stdout.write(o.channel.recv(4096).decode("utf-8", "replace"))
sys.stdout.flush()
if o.channel.recv_stderr_ready():
sys.stdout.write(o.channel.recv_stderr(4096).decode("utf-8", "replace"))
sys.stdout.flush()
time.sleep(0.1)
sys.stdout.write((o.read() + e.read()).decode("utf-8", "replace"))
sys.stdout.flush()
print("->", o.channel.recv_exit_status(), flush=True)
print("## public page + sample image URLs from API", flush=True)
with httpx.Client(follow_redirects=False, timeout=25) as cl:
# try common live/session endpoints
for u in [
"https://dy.nomadro.com/api/health",
"https://dy.nomadro.com/api/sessions",
"https://dy.nomadro.com/api/live",
"https://dy.nomadro.com/api/rooms",
"https://dy.nomadro.com/api/dashboard",
"https://dy.nomadro.com/api/platform/dashboard",
"https://dy.nomadro.com/api/youtube/live-map",
]:
try:
r = cl.get(u)
text = r.text[:500].replace("\n", " ")
print(f"{u} -> {r.status_code} {text[:180]}", flush=True)
except Exception as ex:
print(f"{u} ERR {ex}", flush=True)
print("## caddy cover/s3 routes on VPS", flush=True)
v = connect(22)
run(
v,
"grep -nE 'cover|8333|s3\\.|/covers|nomdfs|Static' /etc/caddy/sites/dy.nomadro.com.caddy | head -40; "
"echo ---; "
"grep -nE 'reverse_proxy 10\\.8\\.0\\.2:8333|reverse_proxy 127\\.0\\.0\\.1:8333|s3.nomadro' /etc/caddy/sites/dy.nomadro.com.caddy | head -20; "
"ss -lntp | grep -E ':(8333|18014|14015)\\b' || true; "
"curl -sS -m 6 -o /dev/null -w 'local_s3=%{http_code}\\n' http://127.0.0.1:8333/ || true; "
"curl -sS -m 6 -o /dev/null -w 'wg_s3=%{http_code}\\n' http://10.8.0.2:8333/ || true; "
"curl -sS -m 6 -o /dev/null -w 'frp_api=%{http_code}\\n' http://127.0.0.1:18014/api/health",
)
v.close()
print("## guest covers/s3", flush=True)
g = connect(4014, "eric", "4669805")
run(
g,
"echo 4669805 | sudo -S -p '' bash -lc '"
"ss -lntp | grep 8333 || true; "
"curl -sS -m 5 http://127.0.0.1:8014/api/health | python3 -c \"import sys,json; d=json.load(sys.stdin); print(d.get(\\\"s3\\\"))\"; "
"curl -sS -m 8 \"http://127.0.0.1:8014/api/sessions\" 2>/dev/null | head -c 400; echo; "
"curl -sS -m 8 \"http://127.0.0.1:8014/api/live\" 2>/dev/null | head -c 400; echo; "
"ls /opt/douyinWEB/backend/data/covers 2>/dev/null | head -5; "
"env | grep -E \"DY_S3|DY_PUBLIC\" 2>/dev/null | head -10; "
"systemctl show douyinweb-api -p Environment 2>/dev/null | tr \" \" \"\\n\" | grep -E \"DY_S3|DY_PUBLIC|DY_COVER\" | head -20"
"'",
t=50,
)
g.close()
print("DONE", flush=True)