fix: harden presentation sync lifecycle

This commit is contained in:
lda
2026-07-14 12:37:11 +07:00 Verified
parent 33d5e0bd4e
commit 783134d5ef
7 changed files with 347 additions and 32 deletions
+5 -3
View File
@@ -15,6 +15,7 @@ import {
} from "@lda/workflow-rpc";
import { createApp, type RunOperation } from "./app.js";
import { createPresentationRoomService } from "./presentation-sync/rooms.js";
import { shutdownServer } from "./shutdown.js";
import { WebSocketServer } from "ws";
const port = Number(process.env.WEB_PORT ?? "8787");
@@ -75,12 +76,13 @@ expirySweep.unref();
console.log(`workflow console server listening on http://${hostname}:${port}`);
let shuttingDown = false;
const shutdown = (signal: NodeJS.Signals) => {
if (shuttingDown) return;
shuttingDown = true;
console.log(`received ${signal}, stopping workflow console server`);
clearInterval(expirySweep);
wss.close();
server.close(() => process.exit(0));
setTimeout(() => process.exit(1), 5_000).unref();
shutdownServer({ server, wss, exit: (code) => process.exit(code) });
};
process.once("SIGINT", shutdown);