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

34 lines
1.6 KiB
Python

# -*- coding: utf-8 -*-
import sys
import time
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[-5000:] if len(out) > 5000 else out, flush=True)
return out
time.sleep(20)
print("[ps]", run("ps aux | grep -E 'ffmpeg|yt-dlp|record' | grep -v grep | head -15"))
print("[clips]", run("ls -lah /opt/douyinWEB/backend/clips/yt_long 2>/dev/null | tail -20; find /opt/douyinWEB/backend/clips/yt_long -type f 2>/dev/null | wc -l"))
print("[jobs]")
print(run(r"""cd /opt/douyinWEB/backend && .venv/bin/python - <<'PY'
from app import db, yt_long_db
from app.yt_long_pipeline import yt_long_pipeline
db.init_db()
# Note: status() on separate process won't show API's running task truthfully for busy counters
st = yt_long_pipeline.status()
print('enabled', st.get('enabled'), 'quota', st.get('quota_used'), '/', st.get('daily_max'), 'gap', st.get('quota_gap'), 'live', st.get('douyin_live_count'))
jobs = yt_long_db.list_yt_long_jobs(limit=20)
for j in jobs:
print(j.get('id')[:8], j.get('status'), j.get('anchor_name'), 'err=', (j.get('error') or '')[:100])
PY"""))
print("[journal]", run("journalctl -u douyinweb-api --since '2 min ago' --no-pager | grep -iE 'yt.long|yt_long|error|Error|Traceback' | tail -30"))
c.close()