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

40 lines
1.7 KiB
Python

# -*- coding: utf-8 -*-
import json
import sys
import paramiko
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, timeout=120):
_, o, e = c.exec_command(cmd, timeout=timeout)
out = (o.read() + e.read()).decode("utf-8", "replace").strip()
print(out[-8000:] if len(out) > 8000 else out, flush=True)
return out
print(run(r"""cd /opt/douyinWEB/backend && .venv/bin/python - <<'PY'
from app import db, yt_long_db
from collections import Counter
import time
db.init_db()
cfg = db.get_settings_map()
print('enabled', cfg.get('yt_long_enabled'))
print('daily_max', cfg.get('yt_long_daily_max'))
print('channel_daily_max', cfg.get('yt_long_channel_daily_max'))
print('max_concurrent', cfg.get('yt_long_max_concurrent'))
print('dedupe', cfg.get('yt_long_dedupe_room_day'))
print('live_sample', cfg.get('yt_long_live_sample'))
jobs = yt_long_db.list_yt_long_jobs(limit=50)
print('status', dict(Counter(j.get('status') for j in jobs)))
now = time.time()
for j in jobs:
age = now - float(j.get('updated_at') or j.get('created_at') or 0)
print(j.get('status'), round(age), 's', (j.get('anchor_name') or '')[:20], 'err=', (j.get('error') or '')[:50], 'clip=', bool(j.get('clip_path')), 'ch=', (j.get('channel_pk') or '')[:8])
print('ffmpeg count:')
PY"""))
print("[ffmpeg]", run("ps aux | grep '[f]fmpeg' | grep yt_long | wc -l; ps aux | grep '[f]fmpeg' | grep yt_long | awk '{print $2,$NF}' | head -20"))
print("[clips]", run("ls -lah /opt/douyinWEB/backend/data/clips/yt_long 2>/dev/null | tail -20"))
c.close()