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>
49 lines
1.8 KiB
Python
49 lines
1.8 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=180):
|
|
_, o, e = c.exec_command(cmd, timeout=timeout)
|
|
out = (o.read() + e.read()).decode("utf-8", "replace").strip()
|
|
print(out[-6000:] if len(out) > 6000 else out, flush=True)
|
|
return out
|
|
|
|
# Restart API so pipeline loads in uvicorn process with enabled=True
|
|
print("[restart api]")
|
|
run("systemctl restart douyinweb-api")
|
|
for _ in range(30):
|
|
if run("systemctl is-active douyinweb-api", timeout=15) == "active":
|
|
break
|
|
time.sleep(2)
|
|
time.sleep(5)
|
|
|
|
print("[in-process check]")
|
|
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)
|
|
print('jobs', len(jobs))
|
|
for j in jobs:
|
|
print(j.get('id')[:8], j.get('status'), j.get('anchor_name'), (j.get('error') or '')[:60])
|
|
# reclaim stuck recording if orphan process died
|
|
import time
|
|
now = time.time()
|
|
for j in jobs:
|
|
if j.get('status') == 'recording':
|
|
age = now - float(j.get('updated_at') or j.get('created_at') or 0)
|
|
print(' recording age_sec', round(age), j.get('id')[:8])
|
|
PY"""))
|
|
|
|
# Call kick via importing same way API does - better: use internal HTTP with auth bypass if any
|
|
# Check how auth works - maybe localhost bypass?
|
|
print("[auth check]", run("curl -sS -m 10 http://127.0.0.1:8014/api/health || curl -sS -m 10 http://127.0.0.1:8014/docs | head -c 200"))
|
|
print("[ffmpeg]", run("ps aux | grep -E 'ffmpeg|yt_long' | grep -v grep | head -20"))
|
|
print("[journal]", run("journalctl -u douyinweb-api -n 40 --no-pager | tail -40"))
|
|
c.close()
|