fix: graceful quit on shutdown #125
This commit is contained in:
@@ -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;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user