Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

feat(api/server): wait 60s for GCE load balancer drain timeout

Gergő Móricza2f41fb65003
diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts
index 933a980f6..05fe005ee 100644
--- a/apps/api/src/index.ts
+++ b/apps/api/src/index.ts
@@ -95,8 +95,13 @@ function startServer(port = DEFAULT_PORT) {
logger.info(`Worker ${process.pid} listening on port ${port}`);
});
- const exitHandler = () => {
+ const exitHandler = async () => {
logger.info("SIGTERM signal received: closing HTTP server");
+ if (process.env.IS_KUBERNETES === "true") {
+ // Account for GCE load balancer drain timeout
+ logger.info("Waiting 60s for GCE load balancer drain timeout");
+ await new Promise((resolve) => setTimeout(resolve, 60000));
+ }
server.close(() => {
logger.info("Server closed.");
process.exit(0);