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

44 lines
1.3 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(host, port, user, pw):
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
for i in range(6):
try:
c.connect(host, port, user, pw, timeout=60, banner_timeout=90, allow_agent=False, look_for_keys=False)
return c
except Exception as ex:
print("fail", i, type(ex).__name__, flush=True)
time.sleep(2 + i)
raise RuntimeError("ssh failed")
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("107.173.30.245", 4014, "eric", "4669805")
print(
run(
g,
"echo '4669805' | sudo -S -p '' bash -lc "
"'docker ps -a --filter name=douyinweb-neko --format \"table {{.Names}}\\t{{.Status}}\\t{{.Ports}}\"; "
"ss -lntp | grep -E \":9200|:52300\" || true; "
"curl -sS -m 5 -o /dev/null -w \"loop:%{http_code}\\n\" http://127.0.0.1:9200/; "
"curl -sS -m 5 -o /dev/null -w \"all:%{http_code}\\n\" http://0.0.0.0:9200/; "
"head -n 80 /opt/douyinWEB/backend/data/neko/docker-compose.yml'",
40,
)
)
g.close()