mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 13:40:44 +00:00
perf(cli): lazy-resolve daemon stop fallback port
This commit is contained in:
@@ -326,6 +326,14 @@ describe("runDaemonRestart health checks", () => {
|
||||
expect(signalVerifiedGatewayPidSync).toHaveBeenCalledWith(4300, "SIGTERM");
|
||||
});
|
||||
|
||||
it("skips gateway port resolution on stop when the service manager handles the stop", async () => {
|
||||
await runDaemonStop({ json: true });
|
||||
|
||||
expect(service.readCommand).not.toHaveBeenCalled();
|
||||
expect(loadConfig).not.toHaveBeenCalled();
|
||||
expect(resolveGatewayPort).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("signals a single unmanaged gateway process on restart", async () => {
|
||||
findVerifiedGatewayListenerPidsOnPortSync.mockReturnValue([4200]);
|
||||
mockUnmanagedRestart({ runPostRestartCheck: true });
|
||||
|
||||
@@ -157,14 +157,17 @@ export async function runDaemonStart(opts: DaemonLifecycleOptions = {}) {
|
||||
|
||||
export async function runDaemonStop(opts: DaemonLifecycleOptions = {}) {
|
||||
const service = resolveGatewayService();
|
||||
const gatewayPort = await resolveGatewayLifecyclePort(service).catch(() =>
|
||||
resolveGatewayPortFallback(),
|
||||
);
|
||||
let gatewayPortPromise: Promise<number> | undefined;
|
||||
return await runServiceStop({
|
||||
serviceNoun: "Gateway",
|
||||
service,
|
||||
opts,
|
||||
onNotLoaded: async () => stopGatewayWithoutServiceManager(gatewayPort),
|
||||
onNotLoaded: async () => {
|
||||
gatewayPortPromise ??= resolveGatewayLifecyclePort(service).catch(() =>
|
||||
resolveGatewayPortFallback(),
|
||||
);
|
||||
return await stopGatewayWithoutServiceManager(await gatewayPortPromise);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user