@n8io/baseline-shutdown 2.1.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ pnpm add @n8io/baseline-shutdown
|
|
|
8
8
|
|
|
9
9
|
## Exports
|
|
10
10
|
|
|
11
|
-
- `
|
|
11
|
+
- `shutdownHandleCreate({ intakes, resources, deadlineMs?, drainDelayMs? })`: owns `SIGTERM`, `SIGINT`, `uncaughtException` and `unhandledRejection`, and exits the process: 0 when every step closed in time, 1 otherwise or after a crash.
|
|
12
12
|
1. Waits `drainDelayMs` (default 5 s; pass 0 outside production) while readiness answers 503.
|
|
13
13
|
2. Closes every intake (HTTP server, live streams, Consumers) at once.
|
|
14
14
|
3. Closes each resource (queue, pools, clients, health, telemetry last) in order.
|
|
@@ -20,10 +20,10 @@ pnpm add @n8io/baseline-shutdown
|
|
|
20
20
|
|
|
21
21
|
```ts
|
|
22
22
|
import { httpServerClose } from "@n8io/baseline-http";
|
|
23
|
-
import {
|
|
23
|
+
import { shutdownHandleCreate } from "@n8io/baseline-shutdown";
|
|
24
24
|
import { telemetryShutdown } from "@n8io/baseline-telemetry";
|
|
25
25
|
|
|
26
|
-
const shutdown =
|
|
26
|
+
const shutdown = shutdownHandleCreate({
|
|
27
27
|
drainDelayMs: envLocal ? 0 : 5_000,
|
|
28
28
|
intakes: [
|
|
29
29
|
{ close: () => httpServerClose(server), name: "http" },
|
package/dist/index.d.ts
CHANGED
|
@@ -11,5 +11,5 @@ type ShutdownOptions = {
|
|
|
11
11
|
export type ShutdownHandle = {
|
|
12
12
|
isShuttingDown(): boolean;
|
|
13
13
|
};
|
|
14
|
-
export declare const
|
|
14
|
+
export declare const shutdownHandleCreate: ({ deadlineMs, drainDelayMs, intakes, resources }: ShutdownOptions) => ShutdownHandle;
|
|
15
15
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ const stepClose = async (kind, step) => {
|
|
|
14
14
|
return false;
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
|
-
const
|
|
17
|
+
const shutdownHandleCreate = ({ deadlineMs = 25e3, drainDelayMs = 5e3, intakes, resources }) => {
|
|
18
18
|
let shuttingDown = false;
|
|
19
19
|
let crashed = false;
|
|
20
20
|
const shutdownRun = async (drainMs) => {
|
|
@@ -69,4 +69,4 @@ const shutdownHandle = ({ deadlineMs = 25e3, drainDelayMs = 5e3, intakes, resour
|
|
|
69
69
|
process.on("unhandledRejection", onCrash);
|
|
70
70
|
return { isShuttingDown: () => shuttingDown };
|
|
71
71
|
};
|
|
72
|
-
export {
|
|
72
|
+
export { shutdownHandleCreate };
|