import type { Config } from "../../config/schema.js"; export interface ServerStartOptions { port?: number; daemon?: boolean; library: string; portfilePath: string; config: Config; } export interface ServerInfo { port: number; pid: number; library: string; started_at?: string; } /** * Start HTTP server. * * @param options - Server start options */ export declare function serverStart(options: ServerStartOptions): Promise; /** * Run shutdown actions for a foreground server: close the HTTP server, flush * library state via dispose(), and remove the portfile. * * Each step is guarded: a failure in one stage logs to stderr and sets * process.exitCode=1, but subsequent stages still run so we do not skip * the save on a close() error or leave a stale portfile on a dispose() * error. Mirrors how dispose() itself is robust to save() failures. * * Intentionally does NOT set process.exitCode on success. dispose() sets * exitCode=1 internally when the shutdown save fails, and unconditionally * writing SUCCESS here would erase that signal and let the CLI exit 0 * despite lost writes. */ export declare function runShutdown(server: { close: () => void; }, dispose: () => Promise, portfilePath: string): Promise; /** * Options for serverStop. */ export interface ServerStopOptions { /** * Interval (ms) between liveness probes while waiting for the server PID * to exit after SIGTERM. Lower values shorten worst-case shutdown latency * but add syscall overhead. Default: 100. */ exitPollIntervalMs?: number; /** * Maximum time (ms) to wait for the server PID to exit after SIGTERM * before giving up and warning. Default: 5000. */ exitWaitTimeoutMs?: number; } /** * Outcome of a PID-exit wait, distinguished so the caller can write a * precise warning: * - "exited": process confirmed gone (ESRCH). * - "timeout": poll loop ran to the deadline with the process still * alive. * - "unreachable": a signal-0 probe threw a non-ESRCH error (e.g. EPERM), * so we cannot tell whether the process exited. */ export interface WaitForPidExitResult { status: "exited" | "timeout" | "unreachable"; /** Error code from the probe that caused an "unreachable" result. */ code?: string; /** Error message from the probe that caused an "unreachable" result. */ message?: string; } /** * Stop running server. * * @param portfilePath - Path to the portfile * @param options - Shutdown-wait tuning (mostly for tests) */ export declare function serverStop(portfilePath: string, options?: ServerStopOptions): Promise; /** * Get server status. * * @param portfilePath - Path to the portfile * @returns Server info if running, null otherwise */ export declare function serverStatus(portfilePath: string): Promise; //# sourceMappingURL=server.d.ts.map