import type { ProcessHost } from './ProcessHost.ts'; import { type RuntimeInterruptLogger } from './runtimeInterrupt.ts'; /** * Maximum time a cooperative shutdown gets before the process is terminated * anyway. Without a ceiling, one resource that never settles (an actor still * inside `startHandler`, a socket that will not drain) holds the process open * forever while every further Ctrl+C is coalesced into the shutdown already * in flight. */ export declare const DEFAULT_SHUTDOWN_TIMEOUT_MS = 15000; /** Session surface the graceful-interrupt path drives. */ export interface InterruptibleSession { requestExit(host: Pick, exitCode: number): Promise; stop(): Promise; } export interface ResolveShutdownTimeoutOptions { /** Fallback when neither an override nor an env value applies. Defaults to {@link DEFAULT_SHUTDOWN_TIMEOUT_MS}. */ readonly defaultMs?: number; /** Environment variable consulted between the override and the default. */ readonly environmentVariable?: string; /** Explicit override; wins over everything. Zero or less disables the watchdog. */ readonly override?: number; } /** * Resolves the shutdown watchdog delay: an explicit override wins, then the * configured environment variable, then the default. A non-numeric or * negative env value is ignored rather than disabling the watchdog by * accident; `0` is honored as "no watchdog". */ export declare function resolveShutdownTimeoutMs(host: Pick, options?: ResolveShutdownTimeoutOptions): number; export interface HandleRuntimeInterruptOptions { /** * Best-effort pre-stop hook, invoked before `session.stop()` — the place to * ask in-flight work to abandon early (cancel provider work, abort long * backfills) so the cooperative stop does not sit behind it. The hook is * awaited within the shutdown watchdog. A throwing or rejecting hook is * reported and does not prevent the stop while time remains. */ readonly onBeforeStop?: () => Promise | void; /** Named in the watchdog-timeout hint so an operator knows which knob allows more time. */ readonly shutdownTimeoutEnvironmentVariable?: string; /** Overrides the resolved shutdown timeout. Zero or less disables the watchdog. */ readonly shutdownTimeoutMs?: number; } /** * Drives one graceful shutdown in response to a process interrupt: announces * it, runs the {@link HandleRuntimeInterruptOptions.onBeforeStop} hook, stops * the session under the watchdog, and requests the outcome-coded exit — * `0` for a clean stop, `1` for a failed or timed-out one. */ export declare function handleRuntimeInterrupt(host: ProcessHost, logger: RuntimeInterruptLogger, session: InterruptibleSession, options?: HandleRuntimeInterruptOptions): Promise; //# sourceMappingURL=handleRuntimeInterrupt.d.ts.map