mirror of https://github.com/openclaw/openclaw.git
fix(gateway): shorten manual reinstall/restart delays
LaunchAgent plist hardcodes ThrottleInterval to 60 in src/daemon/launchd-plist.ts That means every restart/install path that terminates the launchd-managed gateway gets delayed by launchd’s one-minute relaunch throttle. The CLI restart path in src/daemon/launchd.ts is doing the expected supervisor actions, but the plist policy makes those actions look hung. In src/daemon/launchd-plist.ts: - added LAUNCH_AGENT_THROTTLE_INTERVAL_SECONDS - reduced the LaunchAgent ThrottleInterval from 60 to 1
This commit is contained in:
parent
39e09273ca
commit
c0ce125512
|
|
@ -1,5 +1,10 @@
|
|||
import fs from "node:fs/promises";
|
||||
|
||||
// launchd applies ThrottleInterval to any rapid relaunch, including
|
||||
// intentional gateway restarts. Keep it low so CLI restarts and forced
|
||||
// reinstalls do not stall for a full minute.
|
||||
export const LAUNCH_AGENT_THROTTLE_INTERVAL_SECONDS = 1;
|
||||
|
||||
const plistEscape = (value: string): string =>
|
||||
value
|
||||
.replaceAll("&", "&")
|
||||
|
|
@ -106,5 +111,5 @@ export function buildLaunchAgentPlist({
|
|||
? `\n <key>Comment</key>\n <string>${plistEscape(comment.trim())}</string>`
|
||||
: "";
|
||||
const envXml = renderEnvDict(environment);
|
||||
return `<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n<plist version="1.0">\n <dict>\n <key>Label</key>\n <string>${plistEscape(label)}</string>\n ${commentXml}\n <key>RunAtLoad</key>\n <true/>\n <key>KeepAlive</key>\n <true/>\n <key>ThrottleInterval</key>\n <integer>60</integer>\n <key>ProgramArguments</key>\n <array>${argsXml}\n </array>\n ${workingDirXml}\n <key>StandardOutPath</key>\n <string>${plistEscape(stdoutPath)}</string>\n <key>StandardErrorPath</key>\n <string>${plistEscape(stderrPath)}</string>${envXml}\n </dict>\n</plist>\n`;
|
||||
return `<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n<plist version="1.0">\n <dict>\n <key>Label</key>\n <string>${plistEscape(label)}</string>\n ${commentXml}\n <key>RunAtLoad</key>\n <true/>\n <key>KeepAlive</key>\n <true/>\n <key>ThrottleInterval</key>\n <integer>${LAUNCH_AGENT_THROTTLE_INTERVAL_SECONDS}</integer>\n <key>ProgramArguments</key>\n <array>${argsXml}\n </array>\n ${workingDirXml}\n <key>StandardOutPath</key>\n <string>${plistEscape(stdoutPath)}</string>\n <key>StandardErrorPath</key>\n <string>${plistEscape(stderrPath)}</string>${envXml}\n </dict>\n</plist>\n`;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { PassThrough } from "node:stream";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { LAUNCH_AGENT_THROTTLE_INTERVAL_SECONDS } from "./launchd-plist.js";
|
||||
import {
|
||||
installLaunchAgent,
|
||||
isLaunchAgentListed,
|
||||
|
|
@ -199,7 +200,7 @@ describe("launchd install", () => {
|
|||
expect(plist).toContain("<true/>");
|
||||
expect(plist).not.toContain("<key>SuccessfulExit</key>");
|
||||
expect(plist).toContain("<key>ThrottleInterval</key>");
|
||||
expect(plist).toContain("<integer>60</integer>");
|
||||
expect(plist).toContain(`<integer>${LAUNCH_AGENT_THROTTLE_INTERVAL_SECONDS}</integer>`);
|
||||
});
|
||||
|
||||
it("restarts LaunchAgent with bootout-bootstrap-kickstart order", async () => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue