mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-18 12:14:32 +00:00
fix(daemon): honor launchd running state without pid
This commit is contained in:
@@ -554,6 +554,23 @@ describe("launchd install", () => {
|
||||
expect(output).toContain("did not fully stop the service");
|
||||
});
|
||||
|
||||
it("treats launchctl print state=running as running even when pid is missing", async () => {
|
||||
const env = createDefaultLaunchdEnv();
|
||||
const stdout = new PassThrough();
|
||||
let output = "";
|
||||
state.stopLeavesRunning = true;
|
||||
state.printOutput = "state = running\n";
|
||||
stdout.on("data", (chunk: Buffer) => {
|
||||
output += chunk.toString();
|
||||
});
|
||||
|
||||
await stopLaunchAgent({ env, stdout });
|
||||
|
||||
expect(state.launchctlCalls.some((call) => call[0] === "bootout")).toBe(true);
|
||||
expect(output).toContain("Stopped LaunchAgent (degraded)");
|
||||
expect(output).toContain("did not fully stop the service");
|
||||
});
|
||||
|
||||
it("falls back to bootout when launchctl stop itself errors", async () => {
|
||||
const env = createDefaultLaunchdEnv();
|
||||
const stdout = new PassThrough();
|
||||
|
||||
@@ -519,7 +519,10 @@ async function probeLaunchAgentState(serviceTarget: string): Promise<LaunchAgent
|
||||
};
|
||||
}
|
||||
const runtime = parseLaunchctlPrint(probe.stdout || probe.stderr || "");
|
||||
if (typeof runtime.pid === "number" && runtime.pid > 1) {
|
||||
if (
|
||||
normalizeLowercaseStringOrEmpty(runtime.state) === "running" ||
|
||||
(typeof runtime.pid === "number" && runtime.pid > 1)
|
||||
) {
|
||||
return { state: "running" };
|
||||
}
|
||||
return { state: "stopped" };
|
||||
|
||||
Reference in New Issue
Block a user