ServerHandle
A running server.
A running server.
Import#
ts
import type { ServerHandle } from "@shadow-js/dusk/node";
Signature#
ts
interface ServerHandle {
/**
* `"single"` for one process, `"worker"` inside a worker pool, `"primary"` for the process that forks the workers and
* serves nothing (its `server` never listens and its counters stay 0; use `pool`).
*/
readonly role: "single" | "worker" | "primary";
/** The controls of the worker pool; present when `role` is `"primary"`. */
readonly pool?: PoolControl;
/** The port in use (useful with `port: 0`). */
readonly port: number;
readonly host: string;
/** `http(s)://host:port`. */
readonly url: string;
/** The underlying Node server. */
readonly server: Server | HttpsServer;
/** True after shutdown started: new requests get 503. */
readonly draining: boolean;
/** Connections closed at once because `maxConnections` was reached. */
readonly droppedConnections: number;
/** Clients disconnected because they stopped reading their response (`writeTimeoutMs`). */
readonly droppedSlowClients: number;
/**
* Stops accepting connections, lets requests in flight finish for up to `gracefulShutdownMs`,
* then closes what is left. Safe to call more than once.
*/
close(): Promise<void>;
}
Members#
| Name | Type | Description |
|---|---|---|
role |
readonly role: "single" | "worker" | "primary" |
"single" for one process, "worker" inside a worker pool, "primary" for the process that forks the workers and serves nothing (its server never listens and its counters stay 0; use pool). |
pool? |
readonly pool?: PoolControl |
The controls of the worker pool; present when role is "primary". |
port |
readonly port: number |
The port in use (useful with port: 0). |
host |
readonly host: string |
|
url |
readonly url: string |
http(s)://host:port. |
server |
readonly server: Server | HttpsServer |
The underlying Node server. |
draining |
readonly draining: boolean |
True after shutdown started: new requests get 503. |
droppedConnections |
readonly droppedConnections: number |
Connections closed at once because maxConnections was reached. |
droppedSlowClients |
readonly droppedSlowClients: number |
Clients disconnected because they stopped reading their response (writeTimeoutMs). |
close |
close(): Promise<void> |
Stops accepting connections, lets requests in flight finish for up to gracefulShutdownMs, then closes what is left. Safe to call more than once. |