/**
 * Process Manager for Dev Mode
 *
 * Tracks all spawned processes and ensures they're cleaned up on:
 * - Startup failure (any server fails to start)
 * - Runtime crash (uncaught exception)
 * - Graceful shutdown (SIGINT/SIGTERM)
 *
 * This prevents orphan processes and port conflicts between dev sessions.
 */
import type { Logger } from '../../types';
export interface ManagedProcess {
    /** Process identifier for logging */
    id: string;
    /** The process handle */
    process: {
        kill: (signal?: number | NodeJS.Signals) => void;
        exitCode: number | null;
        pid?: number;
    };
    /** Human-readable description */
    description: string;
    /** The port this process uses (if any) */
    port?: number;
    /** Whether this process is critical (startup fails if it dies) */
    critical?: boolean;
}
export interface ManagedServer {
    /** Server identifier */
    id: string;
    /** The server handle */
    server: {
        close: () => void | Promise<void>;
    };
    /** Human-readable description */
    description: string;
    /** The port this server uses */
    port?: number;
}
/**
 * Process Manager
 *
 * Tracks all processes and servers started during dev mode and provides
 * centralized cleanup on failure or shutdown.
 */
export declare class ProcessManager {
    private processes;
    private servers;
    private logger;
    private cleaningUp;
    constructor(logger: Logger);
    /**
     * Register a spawned process for tracking.
     */
    registerProcess(proc: ManagedProcess): void;
    /**
     * Register a server for tracking.
     */
    registerServer(server: ManagedServer): void;
    /**
     * Unregister a process (e.g., after it exits normally).
     */
    unregisterProcess(id: string): void;
    /**
     * Unregister a server.
     */
    unregisterServer(id: string): void;
    /**
     * Get all registered ports (for cleanup verification).
     */
    getPorts(): number[];
    /**
     * Clean up all tracked processes and servers.
     *
     * @param reason - Why cleanup is happening (for logging)
     * @param timeout - Max time to wait for graceful shutdown (ms)
     */
    cleanup(reason: string, timeout?: number): Promise<void>;
    /**
     * Verify that all ports used by tracked processes are released.
     * Used after cleanup to ensure no orphan processes remain.
     */
    verifyPortsReleased(): Promise<{
        port: number;
        released: boolean;
    }[]>;
    /**
     * Check if a port is available.
     */
    private isPortAvailable;
}
/**
 * Get the global process manager (throws if not initialized).
 */
export declare function getProcessManager(): ProcessManager;
/**
 * Initialize the global process manager.
 */
export declare function initProcessManager(logger: Logger): ProcessManager;
/**
 * Cleanup helper that can be called from signal handlers or error handlers.
 */
export declare function cleanupAll(reason: string): Promise<void>;
//# sourceMappingURL=process-manager.d.ts.map