4cfec93458
- Introduced a project-scoped `launch` tool to orchestrate long-running services, debuggers, and watchers with persistent execution capabilities. - Implemented a robust daemon broker with Unix/Windows IPC transport that manages process lifecycles, readiness monitoring, and automatic log rotation. - Added detached process support to ensure services persist independently of the main application lifecycle, including recovery and cleanup mechanisms. - Updated the `bash` interceptor to prioritize the new `launch` tool for background processes and provided comprehensive documentation for lifecycle and signal handling.
18 lines
821 B
TypeScript
18 lines
821 B
TypeScript
import * as path from "node:path";
|
|
import { getConfigRootDir } from "@oh-my-pi/pi-utils";
|
|
|
|
/** Resolve the private runtime directory shared by omp processes in one project directory. */
|
|
export function daemonRuntimeDir(projectDir: string, configRoot: string = getConfigRootDir()): string {
|
|
const key = Bun.hash.wyhash(path.resolve(projectDir)).toString(16).padStart(16, "0");
|
|
return path.join(configRoot, "run", "daemons", key);
|
|
}
|
|
|
|
/** Resolve the Unix socket or Windows named pipe used by one project broker. */
|
|
export function daemonBrokerEndpoint(projectDir: string, runtimeDir: string): string {
|
|
if (process.platform === "win32") {
|
|
const key = Bun.hash.wyhash(path.resolve(projectDir)).toString(16).padStart(16, "0");
|
|
return `\\\\.\\pipe\\omp-daemon-${key}`;
|
|
}
|
|
return path.join(runtimeDir, "broker.sock");
|
|
}
|