# -*- coding: utf-8 -*- """Diagnose why physical douyinweb-api won't listen.""" from __future__ import annotations import sys import paramiko 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", 4014, "eric", "4669805", timeout=40, allow_agent=False, look_for_keys=False) pw = "4669805" def sh(cmd, t=60): _, o, e = c.exec_command(f"echo '{pw}' | sudo -S -p '' bash -lc {repr(cmd)}", timeout=t) return (o.read() + e.read()).decode("utf-8", "replace") print("=== units ===") print(sh("systemctl is-active douyinweb-api douyinweb-api-watch; systemctl show douyinweb-api -p ActiveState,SubState,MainPID,NRestarts,ExecMainStatus,Result --no-pager")) print("=== listen ===") print(sh("ss -ltnp | grep -E '8014|4015' || true; ps -eo pid,etime,rss,cmd | grep -E 'uvicorn|douyinweb-api' | grep -v grep | head -20")) print("=== mem ===") print(sh("free -h; uptime")) print("=== journal ===") print(sh("journalctl -u douyinweb-api -n 80 --no-pager")) print("=== dropins ===") print(sh("systemctl cat douyinweb-api --no-pager | head -80")) c.close()