From 6f46fc0ccd4d95612b68ba4f5e9b228dcf047c72 Mon Sep 17 00:00:00 2001 From: xsl Date: Tue, 22 Sep 2026 23:51:39 +0800 Subject: [PATCH] =?UTF-8?q?docs(gateway):=20=E6=A0=87=E6=B3=A8=E5=9B=BE?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E6=94=B9=E4=B8=BA=20crontab=20=E6=AF=8F?= =?UTF-8?q?=E6=97=A5=E6=B8=85=E7=90=86=E6=97=A7=E6=96=87=E6=A1=88=E5=90=8C?= =?UTF-8?q?=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit app.py 启动日志与 reqlog 注释原写「永久保留,不自动清理」,实际已配置 crontab 每天 03:00 清理 static/annotations 超过 30 天的文件 --- gateway/app.py | 4 ++-- gateway/reqlog.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gateway/app.py b/gateway/app.py index 60a0e81..0250b13 100644 --- a/gateway/app.py +++ b/gateway/app.py @@ -65,10 +65,10 @@ async def lifespan(app: FastAPI): else: app.state._pool_shutdown = None - # 确保标注图目录存在(永久保留,不做定期清理) + # 确保标注图目录存在(超过 30 天的文件由 crontab 每天 03:00 清理) static_dir = Path(cfg["static_dir"]) static_dir.mkdir(parents=True, exist_ok=True) - logger.info("标注图目录: %s(永久保留,不自动清理)", static_dir) + logger.info("标注图目录: %s(>30 天文件由 crontab 每日清理)", static_dir) yield diff --git a/gateway/reqlog.py b/gateway/reqlog.py index 8d5cdcd..9287af1 100644 --- a/gateway/reqlog.py +++ b/gateway/reqlog.py @@ -2,7 +2,7 @@ 设计原则(与用户约定): - 入参/出参日志里**绝不内嵌图片 base64**。图片统一存盘后用 URL 引用,保持日志短小。 -- 入参图片(image_file / *_base64)补存到 static_dir(in_ 前缀),永久保留; +- 入参图片(image_file / *_base64)补存到 static_dir(in_ 前缀); url 输入图本身就在远端,不重新下载,直接记 URL。 - 出参响应在 forward.py 已把 base64 改写成 *_url(无大图),记录完整 data, 但用递归摘要器截断超长结构(landmarks、长字符串),单条上限 ~8KB。 @@ -39,7 +39,7 @@ def save_image_bytes( """把图片字节存盘并返回公网 URL。失败返回 None(不抛异常)。 存到 static_dir/{prefix}{uuid}.{ext},URL = {public_base_url}/static/annotations/{file}。 - 与 forward.py 的 rewrite_base64_to_url 落盘路径/URL 规则一致;文件永久保留,不自动清理。 + 与 forward.py 的 rewrite_base64_to_url 落盘路径/URL 规则一致;超过 30 天的文件由 crontab 每日清理。 """ if not data: return None