#!/usr/bin/env python3 """Probe public S3 image URLs + why DY_S3_ENABLED not applied in process.""" from __future__ import annotations import ssl import sys import time import urllib.error import urllib.request import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") CTX = ssl.create_default_context() URLS = [ "https://s3.nomadro.com/douyin-covers/covers/b9197cd9-b9af-432f-8e2a-880370ce75da.jpg", "https://dy.nomadro.live/douyin-covers/covers/ab13d4f5-9639-40db-a40f-6af8443f3757.jpg", "https://dylive.nomadro.com/douyin-covers/covers/b9197cd9-b9af-432f-8e2a-880370ce75da.jpg", ] for url in URLS: t0 = time.time() try: req = urllib.request.Request(url, method="GET", headers={"User-Agent": "diag"}) with urllib.request.urlopen(req, timeout=20, context=CTX) as r: data = r.read(32) print(f"OK {r.status} t={time.time()-t0:.2f}s ct={r.headers.get('content-type')} len32={len(data)} {url}", flush=True) except urllib.error.HTTPError as e: body = e.read()[:120] print(f"HTTP {e.code} t={time.time()-t0:.2f}s {url} body={body!r}", flush=True) except Exception as ex: print(f"ERR t={time.time()-t0:.2f}s {url} {ex}", flush=True) SCRIPT = r""" set +e echo '=== process env for API pid ===' PID=$(ss -lntp | awk '/:8014/ {match($0,/pid=[0-9]+/); print substr($0,RSTART+4,RLENGTH-4); exit}') echo pid=$PID if [ -n "$PID" ]; then tr '\0' '\n' < /proc/$PID/environ 2>/dev/null | grep -E '^(DY_S3_|DY_PUBLIC|S3_)' | sed -E 's/(SECRET_KEY=).*/\1***/' fi echo echo '=== pydantic settings load test ===' cd /opt/douyinWEB/backend # with systemd env simulated export DY_S3_ENABLED=true export DY_S3_ENDPOINT=http://127.0.0.1:8333 export DY_S3_PUBLIC_BASE=https://s3.nomadro.com ./.venv/bin/python - <<'PY' import os print('env DY_S3_ENABLED=', os.environ.get('DY_S3_ENABLED')) from app.config import settings print('settings.s3_enabled=', settings.s3_enabled, type(settings.s3_enabled)) print('settings.s3_public_base=', settings.s3_public_base) print('model_config=', getattr(settings, 'model_config', None) or getattr(settings, 'Config', None)) PY echo echo '=== caddy s3 routes ===' grep -RniE 's3\.nomadro|8333|douyin-covers|/covers' /etc/caddy /etc/Caddyfile /opt/caddy 2>/dev/null | head -40 ls /etc/caddy/ 2>/dev/null echo HOST_DONE """ for label, host in [("dylive", "107.173.30.245"), ("dy", "108.174.50.68")]: print(f"\n######## {label} {host} ########", flush=True) c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) for i in range(6): try: c.connect(host, 22, "root", "Xiao4669805", timeout=40, allow_agent=False, look_for_keys=False, banner_timeout=120) break except Exception as e: print("retry", e, flush=True) time.sleep(2) else: raise SystemExit("ssh fail") _i, o, e = c.exec_command(SCRIPT, timeout=90) print((o.read() + e.read()).decode("utf-8", "replace"), flush=True) c.close() print("ALL_DONE", flush=True)