#!/usr/bin/env python3 """Diagnose and fix The Lounge + Ergo IRC on production VPS.""" from __future__ import annotations import sys import paramiko import os HOST = os.getenv("NOMAD_SSH_HOST", "82.157.112.245") USER = os.getenv("NOMAD_SSH_USER", "ubuntu") PASSWORD = os.getenv("NOMAD_SSH_PASSWORD", "") COMMANDS = [ "hostname", "systemctl is-active thelounge.service ergo.service 2>&1 || true", "systemctl status thelounge.service --no-pager -l 2>&1 | tail -25", "systemctl status ergo.service --no-pager -l 2>&1 | tail -25", "ss -ltnp 2>/dev/null | grep -E ':9000|:6667' || netstat -ltnp 2>/dev/null | grep -E ':9000|:6667' || true", "curl -sI http://127.0.0.1:9000/ 2>&1 | head -8", "curl -sI https://lounge.nomadro.cn/ 2>&1 | head -10", "journalctl -u thelounge.service -n 30 --no-pager 2>&1", "journalctl -u ergo.service -n 20 --no-pager 2>&1", ] def run_remote(commands: list[str]) -> None: client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.connect(HOST, username=USER, password=PASSWORD, timeout=25) try: for cmd in commands: print(f"\n=== {cmd} ===") _, stdout, stderr = client.exec_command(cmd, timeout=45) out = stdout.read().decode("utf-8", errors="replace") err = stderr.read().decode("utf-8", errors="replace") if out: print(out.rstrip()) if err: print("ERR:", err.rstrip()) finally: client.close() if __name__ == "__main__": run_remote(COMMANDS if len(sys.argv) == 1 else sys.argv[1:])