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>
62 lines
2.6 KiB
Python
62 lines
2.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=180):
|
|
_, o, e = c.exec_command(cmd, timeout=timeout)
|
|
out = (o.read() + e.read()).decode("utf-8", "replace").strip()
|
|
print(out[-10000:] if len(out) > 10000 else out, flush=True)
|
|
return out
|
|
|
|
# mint cookie + call APIs from python on server (no password needed)
|
|
print(run(r"""cd /opt/douyinWEB/backend && .venv/bin/python - <<'PY'
|
|
import json, time, urllib.request
|
|
from app.session_auth import create_session_token, get_admin_credentials, SESSION_COOKIE
|
|
from app import db, yt_long_db
|
|
|
|
user, _ = get_admin_credentials()
|
|
token = create_session_token(user)
|
|
print('user', user)
|
|
|
|
def call(method, path, body=None):
|
|
req = urllib.request.Request(
|
|
f'http://127.0.0.1:8014{path}',
|
|
data=(json.dumps(body).encode() if body is not None else None),
|
|
method=method,
|
|
headers={
|
|
'Cookie': f'{SESSION_COOKIE}={token}',
|
|
'Content-Type': 'application/json',
|
|
},
|
|
)
|
|
with urllib.request.urlopen(req, timeout=120) as resp:
|
|
return json.loads(resp.read().decode())
|
|
|
|
st = call('GET', '/api/yt-long/status')
|
|
print('status1', {k: st.get(k) for k in ['enabled','running','busy','quota_used','quota_gap','daily_max','sampled','processed','last_error','douyin_live_count']})
|
|
st2 = call('POST', '/api/yt-long/start')
|
|
print('start', {k: st2.get(k) for k in ['enabled','running','busy','last_error']})
|
|
sample = call('POST', '/api/yt-long/sample-now')
|
|
print('sample', {k: sample.get(k) for k in ['ok','enqueued','live_count','reason','recording','job_ids']})
|
|
time.sleep(6)
|
|
st3 = call('GET', '/api/yt-long/status')
|
|
print('status2', {k: st3.get(k) for k in ['enabled','running','busy','quota_used','quota_gap','sampled','processed','last_error','douyin_live_count']})
|
|
jobs = call('GET', '/api/yt-long/jobs?limit=10')
|
|
items = jobs.get('jobs') or jobs.get('items') or []
|
|
print('jobs_total', jobs.get('total'), 'n', len(items))
|
|
for j in items[:10]:
|
|
print(' ', j.get('id','')[:8], j.get('status'), j.get('anchor_name'), (j.get('error') or '')[:60])
|
|
# db side
|
|
from collections import Counter
|
|
dbj = yt_long_db.list_yt_long_jobs(limit=20)
|
|
print('db', dict(Counter(j.get('status') for j in dbj)))
|
|
PY"""))
|
|
print("[ffmpeg]", run("ps aux | grep '[f]fmpeg' | head -10"))
|
|
print("[clips]", run("ls -lah /opt/douyinWEB/backend/clips/yt_long | tail -20"))
|
|
c.close()
|