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

57 lines
2.0 KiB
Python

#!/usr/bin/env python3
import sys
import paramiko
if hasattr(sys.stdout, "reconfigure"):
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
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)
script = r"""
cd /opt/douyinWEB/backend
.venv/bin/python - <<'PY'
import asyncio, json, sqlite3
from app import db
from app.douyin import check_room
async def main():
url = 'https://live.douyin.com/81002009942'
cfg = db.get_settings_map()
print('relay_enabled', cfg.get('youtube_relay_enabled'))
print('quality', cfg.get('youtube_relay_quality_preset'))
cookie = str(cfg.get('dy_cookie') or '')
print('cookie_len', len(cookie))
r = await check_room(url, cookie=cookie)
print('room', {k: r.get(k) for k in ['ok','is_live','status','anchor_name','room_id']})
print('stream', (r.get('stream_url') or '')[:120])
print('cands', len(r.get('stream_candidates') or []))
c = sqlite3.connect('/opt/douyinWEB/backend/data/monitor.db')
rows = c.execute("SELECT room_id,last_status,last_anchor FROM rooms WHERE url LIKE '%81002009942%'").fetchall()
print('db_room', rows)
try:
rs = c.execute('SELECT group_id,status,substr(error,1,120),ffmpeg_pid FROM yt_relay_states').fetchall()
print('relay_states', rs)
except Exception as e:
print('relay_err', e)
# settings key table name
try:
for t in c.execute("SELECT name FROM sqlite_master WHERE type='table'").fetchall():
if 'setting' in t[0].lower() or 'yt_assign' in t[0].lower() or 'relay' in t[0].lower():
print('table', t[0])
except Exception:
pass
asyncio.run(main())
PY
pgrep -a ffmpeg | head -3 || echo no_ffmpeg
uptime
"""
_, o, e = c.exec_command(script, timeout=90)
print(o.read().decode("utf-8", "replace"))
err = e.read().decode("utf-8", "replace").strip()
if err:
print("ERR:", err[:800])
c.close()