mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 21:07:01 -06:00
fix: avoid false macOS gateway restart failures (#109955)
* fix: wait through launchd KeepAlive restart throttling * ci: retrigger checks * test: make update restart test platform-independent --------- Co-authored-by: Josh Lehman <josh@martian.engineering>
This commit is contained in:
@@ -202,10 +202,23 @@ async function recoverLaunchAgentAndRecheckGatewayHealth(params: {
|
||||
port: params.port,
|
||||
expectedVersion: params.expectedVersion,
|
||||
env: params.env,
|
||||
supervisorKeepsAlive: true,
|
||||
});
|
||||
return { health, launchAgentRecovery };
|
||||
}
|
||||
|
||||
async function hasLoadedLaunchdKeepAliveSupervisor(params: {
|
||||
service: GatewayService;
|
||||
env?: NodeJS.ProcessEnv;
|
||||
}): Promise<boolean> {
|
||||
if (process.platform !== "darwin") {
|
||||
return false;
|
||||
}
|
||||
// OpenClaw's loaded LaunchAgent has canonical KeepAlive policy. Read this once before
|
||||
// polling so an unloaded agent can still reach the existing recovery path promptly.
|
||||
return await params.service.isLoaded({ env: params.env }).catch(() => false);
|
||||
}
|
||||
|
||||
function formatPostUpdateGatewayRecoveryLine(platform: NodeJS.Platform): string {
|
||||
const restartCommand = replaceCliName(formatCliCommand("openclaw gateway restart"), CLI_NAME);
|
||||
const installCommand = replaceCliName(
|
||||
@@ -248,6 +261,7 @@ if (process.env.VITEST || process.env.NODE_ENV === "test") {
|
||||
formatPostUpdateGatewayRecoveryInstructions,
|
||||
recoverInstalledLaunchAgentAfterUpdate,
|
||||
recoverLaunchAgentAndRecheckGatewayHealth,
|
||||
hasLoadedLaunchdKeepAliveSupervisor,
|
||||
shouldUseLegacyProcessRestartAfterUpdate,
|
||||
};
|
||||
}
|
||||
@@ -1206,12 +1220,17 @@ export async function maybeRestartService(params: {
|
||||
}
|
||||
};
|
||||
const service = resolveGatewayService();
|
||||
let supervisorKeepsAlive = await hasLoadedLaunchdKeepAliveSupervisor({
|
||||
service,
|
||||
env: params.serviceEnv,
|
||||
});
|
||||
let health = await waitForGatewayHealthyRestart({
|
||||
service,
|
||||
port: params.gatewayPort,
|
||||
expectedVersion: expectedGatewayVersion,
|
||||
env: params.serviceEnv,
|
||||
requireRunningService: opts.requireRunningService,
|
||||
supervisorKeepsAlive,
|
||||
});
|
||||
if (!health.healthy && health.staleGatewayPids.length > 0) {
|
||||
if (!params.opts.json) {
|
||||
@@ -1223,12 +1242,17 @@ export async function maybeRestartService(params: {
|
||||
}
|
||||
await terminateStaleGatewayPids(health.staleGatewayPids);
|
||||
await restartAfterStaleCleanup();
|
||||
supervisorKeepsAlive = await hasLoadedLaunchdKeepAliveSupervisor({
|
||||
service,
|
||||
env: params.serviceEnv,
|
||||
});
|
||||
health = await waitForGatewayHealthyRestart({
|
||||
service,
|
||||
port: params.gatewayPort,
|
||||
expectedVersion: expectedGatewayVersion,
|
||||
env: params.serviceEnv,
|
||||
requireRunningService: opts.requireRunningService,
|
||||
supervisorKeepsAlive,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user