























@@ -437,6 +437,11 @@ type LaunchAgentBootstrapRepairResult =
437437| { ok: true; status: "repaired" | "already-loaded" }
438438| { ok: false; status: "bootstrap-failed" | "kickstart-failed"; detail?: string };
439439440+function isLaunchctlAlreadyLoaded(res: { stdout: string; stderr: string; code: number }): boolean {
441+const detail = normalizeLowercaseStringOrEmpty(res.stderr || res.stdout);
442+return res.code === 130 || detail.includes("already exists in domain");
443+}
444+440445export async function repairLaunchAgentBootstrap(args: {
441446env?: Record<string, string | undefined>;
442447}): Promise<LaunchAgentBootstrapRepairResult> {
@@ -450,9 +455,7 @@ export async function repairLaunchAgentBootstrap(args: {
450455let repairStatus: "repaired" | "already-loaded" = "repaired";
451456if (boot.code !== 0) {
452457const detail = (boot.stderr || boot.stdout).trim();
453-const normalized = normalizeLowercaseStringOrEmpty(detail);
454-const alreadyLoaded = boot.code === 130 || normalized.includes("already exists in domain");
455-if (!alreadyLoaded) {
458+if (!isLaunchctlAlreadyLoaded(boot)) {
456459return { ok: false, status: "bootstrap-failed", detail: detail || undefined };
457460}
458461repairStatus = "already-loaded";
@@ -850,12 +853,6 @@ export async function restartLaunchAgent({
850853 plistPath,
851854actionHint: "openclaw gateway restart",
852855});
853-854-const retry = await execLaunchctl(["kickstart", "-k", serviceTarget]);
855-if (retry.code !== 0) {
856-await ensureLaunchAgentLoadedAfterFailure({ domain, serviceTarget, plistPath });
857-throw new Error(`launchctl kickstart failed: ${retry.stderr || retry.stdout}`.trim());
858-}
859856writeLaunchAgentActionLine(stdout, "Restarted LaunchAgent", serviceTarget);
860857return { outcome: "completed" };
861858}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。