douyinWEB/scripts/_cmp_ext_hub_reach.py
2026-09-13 22:10:49 -05:00

53 lines
2.0 KiB
Python

#!/usr/bin/env python3
"""Compare live-ops extension hub reachability: dylive vs dy."""
from __future__ import annotations
import sys
import paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
PASS = "Xiao4669805"
CMD = r"""
echo HOST=$(hostname)
# extension files in running container vs host mount
NAME=$(docker ps --filter name=douyinweb-neko --format '{{.Names}}' | head -1)
echo CONTAINER=$NAME
docker exec "$NAME" head -20 /etc/neko/live-ops-extension/background.js
echo '--- host file ---'
head -20 /opt/douyinWEB/backend/neko/live-ops-extension/background.js
echo '--- from container curl hubs ---'
for u in \
'http://host.docker.internal:8014/api/health' \
'http://172.17.0.1:8014/api/health' \
'http://127.0.0.1:8014/api/health'; do
echo -n "$u -> "
docker exec "$NAME" curl -sS -m 3 -o /dev/null -w '%{http_code}' "$u" 2>/dev/null || echo fail
echo
done
# gateway IP
docker exec "$NAME" getent hosts host.docker.internal 2>/dev/null || true
ip -4 addr show docker0 2>/dev/null | head -3
# recent ingest hits
journalctl -u douyinweb-api --since '20 min ago' --no-pager | grep -c 'live/ingest' || true
journalctl -u douyinweb-api --since '20 min ago' --no-pager | grep 'live/ingest' | tail -5
# compare content.js hash
sha256sum /opt/douyinWEB/backend/neko/live-ops-extension/*.js | awk '{print $2,$1}'
docker exec "$NAME" sha256sum /etc/neko/live-ops-extension/background.js /etc/neko/live-ops-extension/content.js 2>/dev/null
"""
def run(host, name):
print(f"\n===== {name} =====", flush=True)
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect(host, 22, "root", PASS, timeout=30, allow_agent=False, look_for_keys=False)
_i, o, e = c.exec_command(CMD, timeout=60)
print(o.read().decode("utf-8", "replace"), flush=True)
err = e.read().decode("utf-8", "replace")
if err.strip():
print("[stderr]", err[:800], flush=True)
c.close()
run("107.173.30.245", "dylive")
run("108.174.50.68", "dy")
print("DONE", flush=True)