/** * daemon/daemon-control.ts — `aibroker stop` / `aibroker restart` without lsof. * * Order, most cooperative first: * 1. an installed AND active service (systemd user unit / launchd agent) is * driven through its own manager — killing the process behind its back * would only make the manager start it again; * 2. otherwise ask the daemon to shut itself down over IPC (`shutdown`); * 3. otherwise signal the pid in ~/.aibroker/daemon.pid, written at start. * * Everything the steps touch is injected so the order is testable without a * daemon, systemctl or launchctl. */ export declare const SYSTEMD_UNIT = "aibroker.service"; export declare const LAUNCHD_LABEL = "com.aibroker.daemon"; export interface ControlDeps { platform: NodeJS.Platform; home: string; uid: number; exists: (path: string) => boolean; /** Run a command; status is null when it could not be started. */ exec: (cmd: string, args: string[]) => { status: number | null; stdout: string; }; /** Ask the daemon to shut down; rejects when it is unreachable. */ ipcShutdown: () => Promise; /** Is anything answering on the daemon socket? */ socketUp: () => Promise; readPid: () => number | null; kill: (pid: number, signal: NodeJS.Signals | 0) => void; sleep: (ms: number) => Promise; /** Start a detached foreground daemon (restart without a service). */ spawnDaemon: () => void; out: (line: string) => void; } export type StopVia = "service" | "ipc" | "pidfile"; export declare function pidFilePath(home?: string): string; export declare function servicePaths(home: string): { systemd: string; launchd: string; }; /** Stop the daemon; returns which step did it. Throws when nothing was running. */ export declare function stopDaemon(d: ControlDeps): Promise; /** Restart: the service manager restarts its own unit; otherwise stop, then start detached. */ export declare function restartDaemon(d: ControlDeps): Promise; export declare function liveControlDeps(): ControlDeps; export declare function runStopRestart(verb: "stop" | "restart"): Promise; /** Remove the pidfile if it still names this process. */ export declare function removePidFile(home?: string, pid?: number): void; //# sourceMappingURL=daemon-control.d.ts.map