diff --git a/Dockerfile b/Dockerfile index 093016e..3ed2d13 100644 --- a/Dockerfile +++ b/Dockerfile @@ -68,8 +68,19 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libssl3 \ ca-certificates \ curl \ + tzdata \ && rm -rf /var/lib/apt/lists/* +# **必须设 TZ=Asia/Shanghai**(1.0.24 修复): +# 容器默认 TZ=UTC,所有时间显示比北京慢 8h,「今日」配额/趋势日桶 +# 在北京 08:00 切日(不是 00:00)反直觉。`util::day_id` 走 `localtime_r`, +# 设了 TZ 之后自动按上海时区 0:00 切日。 +# +# 对应代码侧:plugin-llm/src/config.rs 的 `RESET_DAY_OFFSET_SEC` 必须从 +# 28800 改为 0(之前手工补 8h 是因为容器 TZ=UTC)。改一处不动的副作用见 +# commit message 与 docs。 +ENV TZ=Asia/Shanghai + COPY --from=builder /src/nginx-${NGINX_VERSION}/objs/nginx /usr/local/nginx/sbin/nginx COPY --from=builder /src/nginx-${NGINX_VERSION}/conf/mime.types /usr/local/nginx/conf/mime.types COPY --from=builder /build/rust/target/release/libipass_gateway.so /usr/local/nginx/modules/ diff --git a/rust/crates/plugin-llm/src/config.rs b/rust/crates/plugin-llm/src/config.rs index 13b2c6a..1f3b101 100644 --- a/rust/crates/plugin-llm/src/config.rs +++ b/rust/crates/plugin-llm/src/config.rs @@ -120,8 +120,20 @@ pub const AFFINITY_TTL_DEFAULT: i64 = 7 * 86400; /// MiniMax 等国内厂商的免费额度按**北京时间**清零,故默认 `28800`(= UTC+8); /// 因此 5 小时窗口是「北京时间当天 0 点起每 5 小时」,一天 24h 不能被 5 整除, /// 末段窗口(20:00–24:00)只有 4 小时、随「天」一起重置(见 `upstreams::cool_until_until`)。 +/// +/// 1.0.24:容器 Dockerfile 已设 `TZ=Asia/Shanghai`,`day_id`/`fmt_time` 直接走 +/// 本地时间 0:00 切日,**不再需要手工补 8h**。此值改成 `0` 与 `util::day_id` +/// 对齐(之前 28800 是因为容器 TZ=UTC + day_id 用 localtime_r 错位到 UTC 日界, +/// 现在两处口径一致都用上海 0:00)。 +/// +/// 副作用:线上 `uda:` / `uex:` 等冷却类键是按 epoch 算的(不走 day_id), +/// 不受影响。**真正受影响的是 `ud:`/`udu:`/`uds:` 趋势日桶的 `tm_yday`**—— +/// +/// 同一天 UTC 算 vs 上海算差 ±1(跨 UTC 16:00 / Shanghai 0:00 边界时), +/// 因此发版后 14 天趋势按新 key 重算,旧 14 天逐步过期(滚动窗口允许丢)。 +/// /// 其他时区的厂商改这里(如 UTC 设 `0`)。 -pub const RESET_DAY_OFFSET_SEC: i64 = 28800; +pub const RESET_DAY_OFFSET_SEC: i64 = 0; // =========================================================================== // 趋势