Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

fix(app): stop command now also stops daemon

Generad0fefc99220
diff --git a/src/app/src/commands/stop.ts b/src/app/src/commands/stop.ts
index 44d58dd0a..f4e97fb22 100644
--- a/src/app/src/commands/stop.ts
+++ b/src/app/src/commands/stop.ts
@@ -1,12 +1,38 @@
import { Command } from "commander";
+import { spawnSync } from "child_process";
+import { dirname, join } from "path";
+import { fileURLToPath } from "url";
import { stopServices } from "../lib/services.js";
+import { buildCliEnv } from "../lib/cli-env.js";
+
+const __dirname = dirname(fileURLToPath(import.meta.url));
+
+function cliEntry(): string {
+ return join(__dirname, "cli", "index.js");
+}
+
+function stopDaemon(): boolean {
+ const status = spawnSync("node", [cliEntry(), "daemon", "status"], {
+ stdio: ["pipe", "pipe", "pipe"],
+ env: buildCliEnv(),
+ });
+ const running = (status.stdout?.toString() ?? "").includes("running (pid=");
+ if (!running) return false;
+
+ spawnSync("node", [cliEntry(), "daemon", "stop"], {
+ stdio: "inherit",
+ env: buildCliEnv(),
+ });
+ return true;
+}
export function stopCommand(): Command {
return new Command("stop")
.description("Stop all Alook services")
.action(() => {
- console.log("Stopping Alook services...");
+ console.log("Stopping Alook services and daemon...");
stopServices();
+ stopDaemon();
console.log("\nAll services stopped.");
});
}