/** * Unified process management for Poltergeist * Consolidates process lifecycle, PID management, heartbeat, and inter-process coordination */ import { type ChildProcess, type SpawnOptions } from 'child_process'; import type { Logger } from '../logger.js'; export interface ProcessInfo { pid: number; hostname: string; isActive: boolean; startTime: string; lastHeartbeat: string; } export interface ProcessOptions { heartbeatInterval?: number; staleThreshold?: number; shutdownTimeout?: number; } export interface ManagedProcess { process: ChildProcess; id: string; startTime: Date; cleanup: () => Promise; } /** * Centralized process management for all Poltergeist operations */ export declare class ProcessManager { private updateHeartbeat; private heartbeatInterval?; private managedProcesses; private shutdownHandlersRegistered; private shutdownHandlers; private logger?; readonly options: Required; constructor(updateHeartbeat: () => void, options?: ProcessOptions, logger?: Logger); /** * Check if a process is still alive by sending signal 0 */ static isProcessAlive(pid: number): boolean; /** * Create process info for the current process */ static createProcessInfo(): ProcessInfo; /** * Update process info with current heartbeat */ static updateProcessInfo(processInfo: ProcessInfo): ProcessInfo; /** * Check if process info indicates a stale/inactive process */ isProcessStale(processInfo: ProcessInfo): boolean; /** * Check if a process belongs to the current process (for lock ownership) */ isOwnProcess(processInfo: ProcessInfo): boolean; /** * Start periodic heartbeat updates */ startHeartbeat(): void; /** * Stop periodic heartbeat updates */ stopHeartbeat(): void; /** * Spawn and manage a child process with automatic cleanup */ spawnManagedProcess(id: string, command: string, args?: string[], options?: SpawnOptions): Promise; /** * Gracefully terminate a process with timeout fallback to SIGKILL * Windows optimization: reduced timeout for faster termination */ terminateProcess(childProcess: ChildProcess, timeoutMs?: number): Promise; /** * Register graceful shutdown handlers for the current process */ registerShutdownHandlers(cleanup: () => Promise): void; /** * Clean up all managed processes */ cleanupAllProcesses(): Promise; /** * Clean up event listeners and shutdown handlers */ cleanupEventListeners(): void; /** * Get information about currently managed processes */ getManagedProcesses(): ReadonlyMap; /** * Get heartbeat age in milliseconds */ getHeartbeatAge(processInfo: ProcessInfo): number; /** * Format heartbeat age as human-readable string */ formatHeartbeatAge(processInfo: ProcessInfo): string; } //# sourceMappingURL=process-manager.d.ts.map