/** Default drain timeout leaves headroom under Kubernetes' default 30 second grace period. */ export declare const DEFAULT_SHUTDOWN_DRAIN_TIMEOUT_MS = 25000; /** Cleanup timeout keeps total shutdown below the default 30 second grace period. */ export declare const DEFAULT_SHUTDOWN_CLEANUP_TIMEOUT_MS = 4000; interface GracefulShutdownRequestTracker { getInFlightCount(): number; waitForDrain(timeoutMs: number): Promise; shutdown(): void; } /** * Inputs required to drain and stop a production server process. * * This lifecycle mutates process-wide readiness, shutdown, and request-tracking * state. Use it once from the process signal handler, not for individual server * instances or requests. */ export interface GracefulProductionShutdownOptions { /** Operating-system signal that initiated shutdown. */ signal: "SIGINT" | "SIGTERM"; /** Maximum drain time. Defaults to SHUTDOWN_DRAIN_TIMEOUT_MS or 25 seconds. */ drainTimeoutMs?: number; /** Total time allowed for cleanup after draining. Defaults to 4 seconds. */ cleanupTimeoutMs?: number; /** Stops signal-aware background work before the HTTP server closes. */ abort: () => void; /** Stops the production HTTP server. */ stop: () => Promise; /** Releases optional bootstrap resources before the server closes. */ dispose?: () => void | Promise; /** Logger used for shutdown progress and failures. */ logger: { info(message: string, context?: Record): void; warn(message: string, context?: unknown): void; }; } interface GracefulProductionShutdownDependencies { markServerShuttingDown: () => void; setServerInitialized: (ready: boolean) => void; requestTracker: GracefulShutdownRequestTracker; shutdownTelemetry: () => Promise; } export declare function parseShutdownDrainTimeoutMs(raw: string | undefined): number; export declare function parseShutdownCleanupTimeoutMs(raw: string | undefined): number; /** * Stops new agent work, drains tracked requests and SSE response bodies, and then * releases server resources. */ export declare function gracefullyShutdownProductionServerWithDependencies(options: GracefulProductionShutdownOptions, dependencies: GracefulProductionShutdownDependencies): Promise; /** * Enter lame-duck mode, mark readiness false, drain tracked requests and SSE * response bodies, and stop a production server process. * * This is a one-shot, process-level lifecycle. Call it once from a SIGINT or * SIGTERM handler. The function returns `true` when every tracked request drains * before the timeout and `false` when cleanup continues after the timeout. */ export declare function gracefullyShutdownProductionServer(options: GracefulProductionShutdownOptions): Promise; export {}; //# sourceMappingURL=graceful-shutdown.d.ts.map