Skip to content

Commit 14a056a

Browse files
authored
fix: stop Gateway without source rebuild (#104357)
1 parent b361390 commit 14a056a

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

.agents/skills/openclaw-live-updater/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Keep `/Users/steipete/openclaw` a read-only-to-the-agent deployment mirror: clea
3030
- Every successful update sets `actions.gatewayBuild` and rebuilds exact new `main` before any restart.
3131
- Missing, invalid, or stale build output also forces a build, even when Git did not move.
3232
- A dependency-input change, absent `node_modules`, or missing/invalid build provenance first runs `pnpm install --frozen-lockfile`.
33-
- Stop the managed Gateway immediately before `pnpm build`; never mutate the live `dist` tree while an old Gateway can dynamically import from it. `pnpm build` must leave both canonical stamp heads and `dist/build-info.json.commit` equal to post-update `afterSha`; any missing/mismatched stamp or required artifact blocks restart.
33+
- Stop the managed Gateway immediately before `pnpm build` by invoking the existing `dist/index.js` directly; source launchers can auto-build stale output before dispatching the stop. Never mutate the live `dist` tree while an old Gateway can dynamically import from it. `pnpm build` must leave both canonical stamp heads and `dist/build-info.json.commit` equal to post-update `afterSha`; any missing/mismatched stamp or required artifact blocks restart.
3434
- Only after exact-SHA build proof may it restart the managed Gateway and require `gateway status --deep --require-rpc --json` plus `health --verbose --json`.
3535
- After every managed restart, query Gateway logs through RPC, restrict the audit to entries emitted since that restart began, report warning summaries, and fail the pass on any error/fatal entry. If RPC verification or log retrieval fails, still inspect the local structured log for that restart window. Never accept supervisor or RPC health without this restart-window log audit.
3636

.agents/skills/openclaw-live-updater/scripts/update-main.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,9 @@ export function maintainMain(options, dependencies = {}) {
747747
runCommand("pnpm", ["install", "--frozen-lockfile"], update.checkout);
748748
}
749749
if (actions.gatewayBuild) {
750-
runCommand("pnpm", ["openclaw", "gateway", "stop"], update.checkout);
750+
// Use the existing built CLI directly. Source launchers may auto-build a
751+
// stale dist before dispatching `gateway stop`, recreating the live-import race.
752+
runCommand(process.execPath, ["dist/index.js", "gateway", "stop"], update.checkout);
751753
runCommand("pnpm", ["build"], update.checkout);
752754
assertExactBuild(update.checkout, update.afterSha);
753755
const restartStartedAt = restartGateway(runCommand, update.checkout, update.afterSha);

test/scripts/openclaw-live-updater.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ describe("openclaw live updater", () => {
371371
});
372372
expect(commands.calls).toEqual([
373373
"pnpm install --frozen-lockfile",
374-
"pnpm openclaw gateway stop",
374+
`${process.execPath} dist/index.js gateway stop`,
375375
"pnpm build",
376376
"pnpm openclaw gateway restart",
377377
"pnpm openclaw gateway status --deep --require-rpc --json",
@@ -418,7 +418,7 @@ describe("openclaw live updater", () => {
418418
expect(output.actions.dependencyInstall).toBe(true);
419419
expect(commands.calls).toEqual([
420420
"pnpm install --frozen-lockfile",
421-
"pnpm openclaw gateway stop",
421+
`${process.execPath} dist/index.js gateway stop`,
422422
"pnpm build",
423423
"pnpm openclaw gateway restart",
424424
"pnpm openclaw gateway status --deep --require-rpc --json",
@@ -549,7 +549,7 @@ describe("openclaw live updater", () => {
549549
).toThrow(/build output does not match/u);
550550
expect(calls).toEqual([
551551
"pnpm install --frozen-lockfile",
552-
"pnpm openclaw gateway stop",
552+
`${process.execPath} dist/index.js gateway stop`,
553553
"pnpm build",
554554
]);
555555
});

0 commit comments

Comments
 (0)