






























@@ -1,26 +1,50 @@
11import fs from "node:fs";
223-const log = fs.readFileSync("/tmp/config-reload-e2e.log", "utf8");
4-const reloadLines = log
5-.split("\n")
6-.filter((line) => line.includes("config change detected; evaluating reload"));
7-const restartLines = log
8-.split("\n")
9-.filter((line) => line.includes("config change requires gateway restart"));
3+const logPath = process.env.OPENCLAW_CONFIG_RELOAD_LOG_PATH ?? "/tmp/config-reload-e2e.log";
4+const deadlineMs = Date.now() + Number(process.env.OPENCLAW_CONFIG_RELOAD_LOG_TIMEOUT_MS ?? 30_000);
10511-if (restartLines.length > 0) {
12-console.error(log.split("\n").slice(-160).join("\n"));
6+const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
7+8+function readLog() {
9+return fs.readFileSync(logPath, "utf8");
10+}
11+12+function inspectLog(log) {
13+const lines = log.split("\n");
14+const reloadLines = lines.filter((line) =>
15+line.includes("config change detected; evaluating reload"),
16+);
17+const restartLines = lines.filter((line) =>
18+line.includes("config change requires gateway restart"),
19+);
20+return { lines, reloadLines, restartLines };
21+}
22+23+let log = "";
24+let result = { lines: [], reloadLines: [], restartLines: [] };
25+26+while (Date.now() < deadlineMs) {
27+log = readLog();
28+result = inspectLog(log);
29+if (result.restartLines.length > 0 || result.reloadLines.length > 0) {
30+break;
31+}
32+await sleep(500);
33+}
34+35+if (result.restartLines.length > 0) {
36+console.error(result.lines.slice(-160).join("\n"));
1337throw new Error("unexpected restart-required reload line found");
1438}
15-for (const line of reloadLines) {
39+for (const line of result.reloadLines) {
1640for (const needle of ["gateway.auth.token", "plugins.entries.firecrawl.config.webFetch"]) {
1741if (line.includes(needle)) {
18-console.error(log.split("\n").slice(-160).join("\n"));
42+console.error(result.lines.slice(-160).join("\n"));
1943throw new Error(`runtime-only path appeared in reload diff: ${needle}`);
2044}
2145}
2246}
23-if (reloadLines.length === 0) {
24-console.error(log.split("\n").slice(-160).join("\n"));
47+if (result.reloadLines.length === 0) {
48+console.error(result.lines.slice(-160).join("\n"));
2549throw new Error("expected config reload detection log after metadata write");
2650}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。