@riddix/hamh 2.1.0-alpha.460 → 2.1.0-alpha.461
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/dist/backend/cli.js
CHANGED
|
@@ -178291,6 +178291,23 @@ async function startHandler(startOptions, webUiDist) {
|
|
|
178291
178291
|
bridgeService.onBridgeChanged = (bridgeId) => {
|
|
178292
178292
|
webApi.websocket.broadcastBridgeUpdate(bridgeId);
|
|
178293
178293
|
};
|
|
178294
|
+
let shuttingDown = false;
|
|
178295
|
+
const gracefulShutdown = async (signal) => {
|
|
178296
|
+
if (shuttingDown) return;
|
|
178297
|
+
shuttingDown = true;
|
|
178298
|
+
console.log(`Received ${signal}, shutting down gracefully...`);
|
|
178299
|
+
try {
|
|
178300
|
+
await Promise.race([
|
|
178301
|
+
bridgeService.dispose(),
|
|
178302
|
+
new Promise((resolve4) => setTimeout(resolve4, 1e4))
|
|
178303
|
+
]);
|
|
178304
|
+
} catch (e) {
|
|
178305
|
+
console.warn("Error during graceful shutdown:", e);
|
|
178306
|
+
}
|
|
178307
|
+
process.exit(0);
|
|
178308
|
+
};
|
|
178309
|
+
process.on("SIGTERM", () => gracefulShutdown("SIGTERM"));
|
|
178310
|
+
process.on("SIGINT", () => gracefulShutdown("SIGINT"));
|
|
178294
178311
|
const initBridges = bridgeService.startAll();
|
|
178295
178312
|
const initApi = webApi.start();
|
|
178296
178313
|
const enableAutoRefresh = initBridges.then(() => registry$).then((r) => r.enableAutoRefresh(() => bridgeService.refreshAll()));
|