nomadro/apps/admin/deploy/_diag_live_apis.py
eric 3e5b7c2098 Monorepo super-optimize: src layout, workspace scripts, docs.
Collapse portal under src/, unify pnpm workspace/scripts, thin VIP topic re-exports, drop orphan vip scaffolds and one-shot scripts, ignore xhs/release, document root commands.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-01 00:34:04 +08:00

47 lines
1.6 KiB
Python

#!/usr/bin/env python3
import paramiko
HOST, USER, PASS = "82.157.112.245", "ubuntu", "Xiao4669805"
CMD = r"""
set +e
echo '=== systemd api-ish ==='
systemctl list-units --type=service --all --no-pager 2>/dev/null | grep -iE 'api|pay|uvicorn|nomad|fastapi|ebook' || true
echo
echo '=== known services ==='
for s in nomadmini-api payjsapi payjsapi-api nomadro-api api ebook-api wemini-api; do
if systemctl status "$s" >/dev/null 2>&1 || systemctl cat "$s" >/dev/null 2>&1; then
echo "-- $s --"
systemctl show "$s" -p Id -p ActiveState -p WorkingDirectory -p FragmentPath -p ExecStart --no-pager 2>/dev/null
echo
fi
done
echo '=== dirs ==='
ls -d /opt/*/backend /opt/*/app /www/wwwroot/*/backend /www/wwwroot/payjsapi /www/wwwroot/api 2>/dev/null
echo
echo '=== ports ==='
ss -lntp 2>/dev/null | grep -E ':(8000|8007|8010|8080)\s' || true
echo
echo '=== curls ==='
for u in \
'https://api.nomadro.cn/health' \
'https://api.nomadro.cn/v1/health' \
'https://api.nomadro.cn/docs' \
'http://127.0.0.1:8000/v1/health' \
'http://127.0.0.1:8007/health' \
'http://127.0.0.1:8010/health'
do
code=$(curl -sk -m 5 -o /tmp/h.txt -w '%{http_code}' "$u"); echo "$code $u"; head -c 120 /tmp/h.txt; echo; echo
done
"""
def main():
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect(HOST, username=USER, password=PASS, timeout=40, allow_agent=False, look_for_keys=False)
_, o, _ = c.exec_command(CMD, timeout=90, get_pty=True)
print(o.read().decode("utf-8", "replace"))
c.close()
if __name__ == "__main__":
main()