fix(update): re-enable launchd service before updater bootstrap

This commit is contained in:
Peter Steinberger
2026-03-09 07:27:02 +00:00
parent cc0f30f5fb
commit 1d3dde8d21
2 changed files with 5 additions and 2 deletions

View File

@@ -98,7 +98,8 @@ describe("restart-helper", () => {
expect(scriptPath.endsWith(".sh")).toBe(true);
expect(content).toContain("#!/bin/sh");
expect(content).toContain("launchctl kickstart -k 'gui/501/ai.openclaw.gateway'");
// Should fall back to bootstrap when kickstart fails (service deregistered after bootout)
// Should clear disabled state and fall back to bootstrap when kickstart fails.
expect(content).toContain("launchctl enable 'gui/501/ai.openclaw.gateway'");
expect(content).toContain("launchctl bootstrap 'gui/501'");
expect(content).toContain('rm -f "$0"');
await cleanupScript(scriptPath);

View File

@@ -95,8 +95,10 @@ rm -f "$0"
# Wait briefly to ensure file locks are released after update.
sleep 1
# Try kickstart first (works when the service is still registered).
# If it fails (e.g. after bootout), re-register via bootstrap then kickstart.
# If it fails (e.g. after bootout), clear any persisted disabled state,
# then re-register via bootstrap and kickstart.
if ! launchctl kickstart -k 'gui/${uid}/${escaped}' 2>/dev/null; then
launchctl enable 'gui/${uid}/${escaped}' 2>/dev/null
launchctl bootstrap 'gui/${uid}' '${escapedPlistPath}' 2>/dev/null
launchctl kickstart -k 'gui/${uid}/${escaped}' 2>/dev/null || true
fi