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>
80 lines
2.1 KiB
Python
80 lines
2.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
import time
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
|
|
def ssh(port, user, pw):
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
for i in range(5):
|
|
try:
|
|
c.connect("107.173.30.245", port, user, pw, timeout=45, banner_timeout=60, allow_agent=False, look_for_keys=False)
|
|
return c
|
|
except Exception as ex:
|
|
print("ssh", i, type(ex).__name__, flush=True)
|
|
time.sleep(2)
|
|
raise RuntimeError("ssh")
|
|
|
|
|
|
def run(c, cmd, timeout=60):
|
|
_, o, e = c.exec_command(cmd, timeout=timeout)
|
|
return (o.read() + e.read()).decode("utf-8", "replace")
|
|
|
|
|
|
g = ssh(4014, "eric", "4669805")
|
|
print("=== journal ===", flush=True)
|
|
print(
|
|
run(
|
|
g,
|
|
"echo '4669805' | sudo -S -p '' journalctl -u douyinweb-api -n 80 --no-pager | tail -80",
|
|
40,
|
|
),
|
|
flush=True,
|
|
)
|
|
|
|
DIAG = r"""
|
|
import sys, traceback
|
|
sys.path.insert(0, "/opt/douyinWEB/backend")
|
|
import os
|
|
os.chdir("/opt/douyinWEB/backend")
|
|
try:
|
|
from app import network_hub
|
|
print("snapshot", network_hub.snapshot())
|
|
except Exception:
|
|
traceback.print_exc()
|
|
try:
|
|
from app import youtube_neko, yt_assign_db
|
|
groups = yt_assign_db.list_groups()
|
|
desired = max([int(g.get("neko_instance_id") or 0) for g in groups] + [1])
|
|
print("status", youtube_neko.status_summary(desired=desired))
|
|
except Exception:
|
|
traceback.print_exc()
|
|
import sqlite3
|
|
con = sqlite3.connect("/opt/douyinWEB/backend/data/monitor.db")
|
|
print("rooms", con.execute("select count(*) from rooms").fetchone()[0])
|
|
con.close()
|
|
from app import global_socks
|
|
print("DEFAULT_PROFILES", global_socks.DEFAULT_PROFILES)
|
|
print("profiles", getattr(global_socks, "get_profiles", lambda: None)())
|
|
"""
|
|
sftp = g.open_sftp()
|
|
with sftp.file("/tmp/_diag_net.py", "w") as f:
|
|
f.write(DIAG)
|
|
sftp.close()
|
|
print("=== diag ===", flush=True)
|
|
print(
|
|
run(
|
|
g,
|
|
"echo '4669805' | sudo -S -p '' /opt/douyinWEB/backend/.venv/bin/python /tmp/_diag_net.py",
|
|
60,
|
|
),
|
|
flush=True,
|
|
)
|
|
g.close()
|