douyinWEB/scripts/_reclaim_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

40 lines
1.3 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[-4000:] if len(out) > 4000 else out, flush=True)
return out
print("[reclaim+wait]")
print(run(r"""cd /opt/douyinWEB/backend && .venv/bin/python - <<'PY'
from app import db, yt_long_db
db.init_db()
# force reclaim any recording stuck after API restart
n = yt_long_db.reclaim_stale_yt_long_recordings(max_age_sec=30)
print('reclaimed', n)
jobs = yt_long_db.list_yt_long_jobs(limit=20)
print('jobs', len(jobs))
for j in jobs:
print(j.get('id')[:8], j.get('status'), j.get('anchor_name'))
PY"""))
time.sleep(12)
print("[ffmpeg]", run("ps aux | grep ffmpeg | grep -v grep | head -10"))
print("[jobs after]")
print(run(r"""cd /opt/douyinWEB/backend && .venv/bin/python - <<'PY'
from app import db, yt_long_db
db.init_db()
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'), (j.get('error') or '')[:80])
PY"""))
c.close()