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

88 lines
2.8 KiB
Python

# -*- coding: utf-8 -*-
"""Deep probe neko-7 Chrome — remote script via sftp."""
from __future__ import annotations
import sys
import time
import paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
PASS = "4669805"
REMOTE = r'''#!/bin/bash
set -euo pipefail
NAME=douyinweb-neko-7
echo === pid 5271 ===
docker exec "$NAME" bash -lc 'ls -l /proc/5271 2>/dev/null || echo no_5271; tr "\0" " " < /proc/5271/cmdline 2>/dev/null; echo; head -15 /proc/5271/status 2>/dev/null || true'
echo === chrome pids ===
docker exec "$NAME" bash -lc 'for d in /proc/[0-9]*; do c=$(tr "\0" " " < "$d/cmdline" 2>/dev/null || true); case "$c" in *chrome*|*chromium*) echo "$d $c";; esac; done | head -50'
echo === ports 9222 ===
docker exec "$NAME" python3 - <<'PY'
import socket
for port in (9222, 8080, 5900, 5700):
s = socket.socket()
s.settimeout(1)
try:
r = s.connect_ex(("127.0.0.1", port))
print(port, "open" if r == 0 else "closed", r)
finally:
s.close()
PY
echo === launch conf ===
docker exec "$NAME" bash -lc 'grep -RIn "remote-debugging\|google-chrome\|chromium" /etc/supervisor /etc/neko 2>/dev/null | head -40; echo ---; ls /etc/supervisor/conf.d 2>/dev/null; for f in /etc/supervisor/conf.d/*; do echo FILE $f; sed -n "1,80p" "$f"; done'
echo === x windows ===
docker exec "$NAME" bash -lc 'command -v xdotool; command -v xwininfo; DISPLAY=:0.0 xwininfo -root -tree 2>&1 | head -40 || true'
echo === assign ===
cd /opt/douyinWEB/backend
PYTHONPATH=/opt/douyinWEB/backend .venv/bin/python - <<'PY'
from app import yt_assign_db
for g in yt_assign_db.list_groups(include_urls=True):
if int(g.get("neko_instance_id") or 0) != 7:
continue
print("name", g.get("name"))
print("neko_studio_url", g.get("neko_studio_url"))
print("neko_enabled", g.get("neko_enabled"))
print("featured", len(g.get("featured") or []))
PY
echo DEEP_OK
'''
def main() -> int:
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
for i in range(10):
try:
c.connect(
"107.173.30.245",
4014,
"eric",
PASS,
timeout=45,
banner_timeout=120,
allow_agent=False,
look_for_keys=False,
)
break
except Exception as ex:
print("ssh", i, type(ex).__name__, flush=True)
time.sleep(2)
else:
return 1
sftp = c.open_sftp()
with sftp.file("/tmp/_diag_neko7_deep.sh", "w") as f:
f.write(REMOTE)
sftp.close()
_, o, e = c.exec_command(
f"echo '{PASS}' | sudo -S -p '' bash /tmp/_diag_neko7_deep.sh",
timeout=90,
)
print((o.read() + e.read()).decode("utf-8", "replace"))
c.close()
return 0
if __name__ == "__main__":
raise SystemExit(main())