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>
68 lines
2.3 KiB
Python
68 lines
2.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
import json
|
|
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[-7000:] if len(out) > 7000 else out, flush=True)
|
|
return out
|
|
|
|
print("[sql reset]")
|
|
print(run(r"""cd /opt/douyinWEB/backend && .venv/bin/python - <<'PY'
|
|
from app import db, yt_long_db
|
|
from app.yt_long_db import _connect, _lock
|
|
import time
|
|
db.init_db()
|
|
with _lock:
|
|
conn = _connect()
|
|
try:
|
|
cur = conn.execute(
|
|
"UPDATE yt_long_jobs SET status='pending', started_at=0, error='manual_reset', updated_at=? WHERE status IN ('recording','uploading')",
|
|
(time.time(),),
|
|
)
|
|
conn.commit()
|
|
print('reset', cur.rowcount)
|
|
finally:
|
|
conn.close()
|
|
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'))
|
|
PY"""))
|
|
|
|
h = run("curl -sS -m 15 http://127.0.0.1:8014/api/health")
|
|
try:
|
|
data = json.loads(h)
|
|
print("[health keys]", sorted(data.keys()))
|
|
for k in sorted(data.keys()):
|
|
if "yt" in k.lower() or "long" in k.lower() or k in ("shorts", "tiktok", "x_clips"):
|
|
v = data[k]
|
|
if isinstance(v, dict):
|
|
print(k, {kk: v.get(kk) for kk in list(v)[:12]})
|
|
else:
|
|
print(k, v)
|
|
except Exception as exc:
|
|
print("parse fail", exc, h[:300])
|
|
|
|
time.sleep(10)
|
|
print("[after 10s]")
|
|
print(run(r"""cd /opt/douyinWEB/backend && .venv/bin/python - <<'PY'
|
|
from app import db, yt_long_db
|
|
from collections import Counter
|
|
db.init_db()
|
|
jobs = yt_long_db.list_yt_long_jobs(limit=50)
|
|
print(dict(Counter(j.get('status') for j in jobs)))
|
|
for j in jobs[:10]:
|
|
print(j.get('id')[:8], j.get('status'), j.get('anchor_name'), (j.get('error') or '')[:80])
|
|
PY"""))
|
|
print("[ffmpeg]", run("ps aux | grep '[f]fmpeg' | head -8"))
|
|
print("[clips]", run("mkdir -p /opt/douyinWEB/backend/clips/yt_long; ls -lah /opt/douyinWEB/backend/clips/yt_long | tail -15"))
|
|
c.close()
|