mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 05:11:25 +00:00
refactor: unify gateway restart deferral and dispatcher cleanup
This commit is contained in:
@@ -6,7 +6,9 @@ import { ensureBinary } from "./binaries.js";
|
||||
import {
|
||||
__testing,
|
||||
consumeGatewaySigusr1RestartAuthorization,
|
||||
emitGatewayRestart,
|
||||
isGatewaySigusr1RestartExternallyAllowed,
|
||||
markGatewaySigusr1RestartHandled,
|
||||
scheduleGatewaySigusr1Restart,
|
||||
setGatewaySigusr1RestartPolicy,
|
||||
setPreRestartDeferralCheck,
|
||||
@@ -100,6 +102,25 @@ describe("infra runtime", () => {
|
||||
setGatewaySigusr1RestartPolicy({ allowExternal: true });
|
||||
expect(isGatewaySigusr1RestartExternallyAllowed()).toBe(true);
|
||||
});
|
||||
|
||||
it("suppresses duplicate emit until the restart cycle is marked handled", () => {
|
||||
const emitSpy = vi.spyOn(process, "emit");
|
||||
const handler = () => {};
|
||||
process.on("SIGUSR1", handler);
|
||||
try {
|
||||
expect(emitGatewayRestart()).toBe(true);
|
||||
expect(emitGatewayRestart()).toBe(false);
|
||||
expect(consumeGatewaySigusr1RestartAuthorization()).toBe(true);
|
||||
|
||||
markGatewaySigusr1RestartHandled();
|
||||
|
||||
expect(emitGatewayRestart()).toBe(true);
|
||||
const sigusr1Emits = emitSpy.mock.calls.filter((args) => args[0] === "SIGUSR1");
|
||||
expect(sigusr1Emits.length).toBe(2);
|
||||
} finally {
|
||||
process.removeListener("SIGUSR1", handler);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("pre-restart deferral check", () => {
|
||||
|
||||
Reference in New Issue
Block a user