Ship zombie reconcile, S3 covers, session end/drill-down, rooms ops, and refresh README for production. Co-authored-by: Cursor <cursoragent@cursor.com>
66 lines
2.4 KiB
Python
66 lines
2.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Inspect why active/recent sessions have no covers."""
|
|
import json
|
|
import time
|
|
import paramiko
|
|
|
|
HOST = "107.173.30.245"
|
|
USER = "root"
|
|
PASSWORD = "Xiao4669805"
|
|
|
|
SCRIPT = r'''
|
|
import json, sqlite3, time, os
|
|
db="/opt/douyinWEB/backend/data/monitor.db"
|
|
conn=sqlite3.connect(db)
|
|
conn.row_factory=sqlite3.Row
|
|
now=time.time()
|
|
# today sessions without cover
|
|
rows=conn.execute("""
|
|
SELECT id, anchor_name, room_id, status, started_at, ended_at, cover_path, duration_seconds, push_date
|
|
FROM sessions
|
|
WHERE push_date=date('now','localtime')
|
|
ORDER BY started_at DESC
|
|
""").fetchall()
|
|
total=len(rows)
|
|
no_cover=[dict(r) for r in rows if not (r['cover_path'] or '').strip()]
|
|
with_cover=total-len(no_cover)
|
|
print(f"today_total={total} with_cover={with_cover} no_cover={len(no_cover)}")
|
|
print("--- no_cover sample ---")
|
|
for r in no_cover[:20]:
|
|
el=now-float(r['started_at'] or 0)
|
|
print(f"{r['anchor_name']!r} status={r['status']} cover={r['cover_path']!r} started_ago_h={el/3600:.2f} id={r['id'][:8]}")
|
|
# focus names
|
|
for name in ["雨汐","大墨鱼"]:
|
|
print("--- focus", name)
|
|
for r in conn.execute("SELECT id,anchor_name,status,cover_path,started_at,ended_at FROM sessions WHERE anchor_name LIKE ? ORDER BY started_at DESC LIMIT 5",(f"%{name}%",)):
|
|
print(dict(r))
|
|
# settings related
|
|
print("--- settings ---")
|
|
for r in conn.execute("SELECT key,value FROM settings WHERE key LIKE '%cover%' OR key LIKE '%ffmpeg%' OR key LIKE '%s3%' OR key LIKE '%seaweed%'"):
|
|
print(dict(r))
|
|
# env / service
|
|
print("--- cover dir ---")
|
|
import glob
|
|
print("local covers count", len(glob.glob('/opt/douyinWEB/backend/data/covers/*')))
|
|
print("s3 env", {k:os.environ.get(k,'')[:40] for k in ['S3_ENDPOINT','S3_BUCKET','S3_PUBLIC_BASE','AWS_ACCESS_KEY_ID']})
|
|
'''
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(HOST, 22, USER, PASSWORD, timeout=30, allow_agent=False, look_for_keys=False)
|
|
sftp = c.open_sftp()
|
|
sftp.putfo(__import__("io").BytesIO(SCRIPT.encode()), "/tmp/check_covers.py")
|
|
# better write via open
|
|
sftp.close()
|
|
|
|
chan = c.get_transport().open_session()
|
|
chan.settimeout(60)
|
|
chan.exec_command("/opt/douyinWEB/backend/.venv/bin/python - <<'PY'\n" + SCRIPT + "\nPY")
|
|
import sys
|
|
out = chan.recv(1 << 20).decode("utf-8", "replace")
|
|
err = chan.recv_stderr(1 << 20).decode("utf-8", "replace")
|
|
print(out)
|
|
if err.strip():
|
|
print("ERR", err[-1500:])
|
|
c.close()
|