Skip to content

Commit 70410d3

Browse files
committed
Ability to change the timeout of the graceful shutdown via env var
1 parent 6371dd4 commit 70410d3

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

apps/webapp/server.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,23 @@ if (process.env.HTTP_SERVER_DISABLED !== "true") {
6262
});
6363

6464
// Handle shutdowns gracefully
65-
createTerminus(server, { signals: ["SIGINT", "SIGTERM"], timeout: 5000 });
65+
createTerminus(server, {
66+
signals: ["SIGINT", "SIGTERM"],
67+
timeout: process.env.GRACEFUL_SHUTDOWN_TIMEOUT
68+
? Number(process.env.GRACEFUL_SHUTDOWN_TIMEOUT)
69+
: 5000,
70+
onSignal: async () => {
71+
console.log("[terminus] onSignal: starting cleanup");
72+
},
73+
onShutdown: async () => {
74+
console.log("[terminus] onShutdown: cleanup finished, server is shutting down");
75+
},
76+
onSendFailureDuringShutdown: async () => {
77+
console.log(
78+
"[terminus] onSendFailureDuringShutdown: cleanup finished, server is shutting down"
79+
);
80+
},
81+
});
6682
} else {
6783
console.log(`✅ app ready (skipping http server)`);
6884
}

0 commit comments

Comments
 (0)