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

71 lines
2.4 KiB
Python

# -*- coding: utf-8 -*-
import sys
import paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
REMOTE = r"""
echo "=== seaweed/s3 services ==="
systemctl is-active douyinweb-s3 douyinweb-sw-master douyinweb-sw-volume douyinweb-sw-filer 2>/dev/null || true
echo "=== s3 env ==="
grep -E '^DY_S3|^S3_' /etc/douyinweb.env 2>/dev/null || echo "(no s3 in env)"
grep -E 's3_' /opt/douyinWEB/backend/app/config.py | head -8
echo "=== health s3 ==="
curl -sS http://127.0.0.1:8014/api/health | python3 -c "import sys,json; d=json.load(sys.stdin); print(json.dumps(d.get('s3',{}), indent=2, ensure_ascii=False))" 2>/dev/null || curl -sS http://127.0.0.1:8014/api/health | head -c 800
echo "=== s3 port 8333 ==="
curl -sS -o /dev/null -w "s3_head=%{http_code}\n" http://127.0.0.1:8333/ 2>/dev/null || echo s3_unreachable
echo "=== active sessions covers ==="
cd /opt/douyinWEB/backend
.venv/bin/python - <<'PY'
from app import db, config
from app import s3_storage
print("s3_enabled_cfg", config.settings.s3_enabled)
print("s3_enabled_runtime", s3_storage.s3_enabled())
print("s3_endpoint", config.settings.s3_endpoint)
print("s3_public_base", config.settings.s3_public_base)
print("s3_bucket", config.settings.s3_bucket)
active = db.list_active_sessions()
print("active_sessions", len(active))
for s in active[:8]:
print(
s.get("id", "")[:8],
"|",
(s.get("anchor_name") or s.get("room_id") or "")[:24],
"| cover_path",
(s.get("cover_path") or "")[:60],
"| platform",
(s.get("metadata") or {}).get("platform") if isinstance(s.get("metadata"), dict) else "",
)
recent = db.list_sessions(limit=5)
print("recent_sessions", len(recent))
for s in recent[:5]:
row = db.session_row_to_api(s) if hasattr(db, "session_row_to_api") else s
print(
"recent",
(row.get("anchor_name") or row.get("room_id") or "")[:20],
"cover_url",
(row.get("cover_url") or "")[:70],
)
PY
echo "=== local covers dir ==="
ls -la /opt/douyinWEB/backend/data/covers 2>/dev/null | head -8 || echo no_local_covers
"""
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)
_i, o, e = c.exec_command(REMOTE, timeout=120)
print(o.read().decode("utf-8", "replace"))
err = e.read().decode("utf-8", "replace").strip()
if err:
print("ERR", err[:1500])
c.close()