#!/usr/bin/env python3 """Diagnose Douyin config 500 and fix parents IndexError on server.""" from __future__ import annotations import paramiko HOST, USER, PASS = "82.157.112.245", "ubuntu", "Xiao4669805" REMOTE = r""" set -e echo '=== journal ===' sudo journalctl -u nomadmini-api -n 40 --no-pager | tail -40 echo '=== local import test ===' cd /opt/nomadmini/backend sudo -u ubuntu python3 <<'PY' import sys sys.path.insert(0, '.') try: from app.services.tt_platform_config import read_tt_platform, resolve_config_file, _candidate_paths print('path', resolve_config_file()) print('cands', [str(p) for p in _candidate_paths()]) cfg = read_tt_platform() print('ok modules', list((cfg.get('modules') or {}).keys())) print('chapters', len((cfg.get('bookContent') or {}).get('chapters') or [])) except Exception as e: import traceback traceback.print_exc() PY echo '=== curl config no auth ===' curl -sk -o /tmp/dy_cfg.json -w "http %{http_code}\n" https://admin.nomadro.cn/api/admin/douyin/config head -c 300 /tmp/dy_cfg.json; echo """ def main() -> int: 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) _, stdout, stderr = c.exec_command(REMOTE, timeout=120, get_pty=True) out = stdout.read().decode("utf-8", "replace") err = stderr.read().decode("utf-8", "replace") print(out) if err.strip(): print("STDERR", err) c.close() return 0 if __name__ == "__main__": raise SystemExit(main())