浏览代码

M11 NATS fix: use config file for JetStream limits (correct path)

NATS 2.10 doesn't expose max_store / max_mem as CLI flags (the
'-ms' flag is for HTTPS port, not max_storage). The first attempt
used '-ms 10G' which made the container exit immediately.

This fix:
  - Adds deploy/nats/nats.conf with the JetStream block:
      max_store: 10 GiB
      max_mem:   1 GiB
  - Mounts the config file into the container at /etc/nats/nats.conf
  - Adds '-c /etc/nats/nats.conf' to the command (alongside -js, -sd, -m)
  - The broker.go change (stream-level MaxAge=1h + MaxBytes safety
    caps) is unchanged from f450196.

This is the actual deployment shape for the M11 NATS fix.
Luis Rosales 1 月之前
父节点
当前提交
6c82dcf
共有 2 个文件被更改,包括 45 次插入10 次删除
  1. 35 0
      deploy/nats/nats.conf
  2. 10 10
      docker-compose.yml

+ 35 - 0
deploy/nats/nats.conf

@@ -0,0 +1,35 @@
+# nats.conf — NATS server config for the broad-announce dev/playground
+# environment. Mirrors what was previously set via CLI flags, plus
+# the JetStream limits that 2.10 does not expose as CLI flags.
+#
+# Mounted at /etc/nats/nats.conf by docker-compose. Loaded via -c flag.
+#
+# See M11_NATS_INVESTIGATION.md for why max_store is 10G and why
+# we have stream-level MaxBytes/MaxAge in broker.go (not here).
+
+# Client port (apps connect to nats:4222)
+port: 4222
+
+# HTTP monitoring port (Prometheus + ops access)
+monitor_port: 8222
+
+# Disable per-message tracing in dev (we use structured logging elsewhere)
+# trace: true
+
+# JetStream configuration.
+# max_store:  hard cap on disk-backed storage. With 11 GiB free on
+#             parres (post-prune 2026-06-16), 10 GiB gives a safety
+#             margin while still being well above the actual stream
+#             usage (~1.1 GiB after the broker.go fix).
+# max_mem:    hard cap on memory-backed storage. Set to 1 GiB
+#             (parres has 16 GiB total RAM; ollama + prometheus +
+#             clickhouse + grafana use the rest). Streams we declare
+#             are file-backed, so this only matters for any future
+#             memory-backed streams.
+# store_dir:  where JetStream writes its files. Mounted from the
+#             natsdata docker volume.
+jetstream {
+  store_dir: /data/jetstream
+  max_store: 10737418240   # 10 GiB
+  max_mem:   1073741824    # 1 GiB
+}

+ 10 - 10
docker-compose.yml

@@ -41,19 +41,19 @@ services:
 
   nats:
     image: nats:2.10-alpine
-    # -js        : JetStream enabled
-    # -sd /data  : store dir (mounted from natsdata volume)
-    # -m 8222    : HTTP monitoring port
-    # -ms 10G    : max_storage cap. M11 NATS investigation set
-    #              this explicitly after the default (~5.5 GiB on
-    #              parres with 6.5 GiB free) was exceeded by
-    #              accumulated ALERTS data. With the docker prune
-    #              (2026-06-16) we now have 11 GiB free, so 10G
-    #              is safe. See M11_NATS_INVESTIGATION.md.
-    command: ["-js", "-sd", "/data", "-m", "8222", "-ms", "10G"]
+    # -js              : JetStream enabled
+    # -sd /data        : store dir (mounted from natsdata volume)
+    # -m 8222          : HTTP monitoring port
+    # -c /etc/nats/nats.conf : load the JetStream limits from a
+    #              config file. 2.10 does not expose max_store /
+    #              max_mem as CLI flags; they have to come from a
+    #              .conf. See deploy/nats/nats.conf and
+    #              M11_NATS_INVESTIGATION.md.
+    command: ["-js", "-sd", "/data", "-m", "8222", "-c", "/etc/nats/nats.conf"]
     ports: ["4222:4222", "8222:8222"]   # 8222 is the monitoring HTTP
     volumes:
       - natsdata:/data
+      - ./deploy/nats/nats.conf:/etc/nats/nats.conf:ro
     healthcheck:
       test: ["CMD", "wget", "-qO-", "http://localhost:8222/healthz"]
       interval: 5s