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>
48 lines
1.7 KiB
Python
48 lines
1.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
import paramiko
|
|
import time
|
|
import sys
|
|
|
|
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)
|
|
|
|
# force start if stuck stopping
|
|
c.exec_command("systemctl restart douyinweb-api", timeout=10)
|
|
time.sleep(12)
|
|
|
|
def run(cmd, timeout=30):
|
|
_, o, e = c.exec_command(cmd, timeout=timeout)
|
|
return (o.read() + e.read()).decode("utf-8", "replace").strip()
|
|
|
|
print("api:", run("systemctl is-active douyinweb-api"))
|
|
print("health:", run("curl -sS -m 8 http://127.0.0.1:8014/api/health"))
|
|
print(run(r"""
|
|
python3 - <<'PY'
|
|
import urllib.request, json
|
|
for path in ['/api/shorts/channels','/api/yt-long/channels','/api/tiktok/channels','/api/rooms?limit=1']:
|
|
try:
|
|
with urllib.request.urlopen('http://127.0.0.1:8014'+path, timeout=10) as r:
|
|
data=json.loads(r.read().decode())
|
|
if 'channels' in data:
|
|
print(path, 'channels=', len(data.get('channels') or []))
|
|
elif 'rooms' in data:
|
|
print(path, 'rooms=', len(data.get('rooms') or []), 'total=', data.get('total'))
|
|
else:
|
|
print(path, list(data.keys())[:8])
|
|
except Exception as e:
|
|
print(path, 'ERR', e)
|
|
# confirm db untouched
|
|
import sqlite3
|
|
conn=sqlite3.connect('file:/opt/douyinWEB/backend/data/monitor.db?mode=ro', uri=True)
|
|
for t in ['shorts_channels','yt_long_channels','rooms','tiktok_channels']:
|
|
print('db', t, conn.execute(f'select count(*) from {t}').fetchone()[0])
|
|
conn.close()
|
|
PY
|
|
"""))
|
|
print("last err:")
|
|
print(run("journalctl -u douyinweb-api -n 8 --no-pager -o cat | tail -8")[-1200:])
|
|
c.close()
|