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

32 lines
1.3 KiB
Python

# -*- coding: utf-8 -*-
import sys, 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):
_, o, e = c.exec_command(cmd, timeout=60)
return (o.read()+e.read()).decode("utf-8","replace").strip()
print(run(r"""cd /opt/douyinWEB/backend && .venv/bin/python -c "
from app import db
db.init_db()
from app.db import _connect, _lock
import time
with _lock:
conn = _connect()
try:
rows = conn.execute('SELECT id,kind,status,account_username,received_at,progress_message,error FROM x2_jobs ORDER BY received_at DESC LIMIT 20').fetchall()
for r in rows:
d = dict(r)
print(d)
print('---')
total = conn.execute('SELECT status, COUNT(*) c FROM x2_jobs GROUP BY status').fetchall()
print('x2_jobs:', {r['status']:r['c'] for r in total})
cutoff = time.time() - 3600
recent = conn.execute('SELECT kind, status, COUNT(*) c FROM x2_jobs WHERE received_at > ? GROUP BY kind, status', (cutoff,)).fetchall()
print('last1h:', [(r['kind'],r['status'],r['c']) for r in recent])
finally:
conn.close()
" """))
c.close()