fix: graceful quit on shutdown #125

This commit is contained in:
leukipp
2025-11-10 14:46:15 +01:00
parent a3860ebd69
commit 4f8a9c307c
+10 -2
View File
@@ -6,7 +6,7 @@ const integration = require("./js/integration");
const hardware = require("./js/hardware"); const hardware = require("./js/hardware");
const webview = require("./js/webview"); const webview = require("./js/webview");
const log = require("electron-log"); const log = require("electron-log");
const { app } = require("electron"); const { app, powerMonitor } = require("electron");
const Events = require("events"); const Events = require("events");
global.APP = global.APP || {}; global.APP = global.APP || {};
@@ -124,12 +124,20 @@ const initApp = async () => {
console[level](`${APP.title} Terminated (${process.exitCode})`); console[level](`${APP.title} Terminated (${process.exitCode})`);
app.exit(process.exitCode); app.exit(process.exitCode);
}); });
["SIGINT", "SIGTERM", "SIGQUIT"].forEach((signal) => {
// Register process exit events
["SIGINT", "SIGTERM", "SIGQUIT", "exit"].forEach((signal) => {
process.on(signal, () => { process.on(signal, () => {
process.exitCode = 0; process.exitCode = 0;
APP.exiting = true;
app.quit(); app.quit();
}); });
}); });
powerMonitor.on("shutdown", () => {
process.exitCode = 0;
APP.exiting = true;
app.quit();
});
return true; return true;
}; };