desktop: gracefully shutdown on sigint/sigterm/sigquit

This commit is contained in:
DH
2025-09-07 16:13:02 +03:00
parent b78eb4610e
commit f4158a1ceb
2 changed files with 20 additions and 4 deletions

View File

@@ -86,20 +86,35 @@ export async function initialize() {
}
});
app.on('window-all-closed', async () => {
let shutdownRequested = false;
const shutdown = async () => {
if (shutdownRequested) {
return;
}
shutdownRequested = true;
app.quit();
try {
await core.shutdown(undefined);
} catch (e) {
console.error("shutdown throws exception", e);
}
};
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
shutdown();
}
});
await app.whenReady();
process.on('SIGINT', () => shutdown());
process.on('SIGTERM', () => shutdown());
process.on('SIGQUIT', () => shutdown());
const uiPath = path.join(import.meta.dirname, "ui");
const fixPath = async (loc: PathLike) => {

View File

@@ -82,7 +82,8 @@ class JsonRpcProtocol implements ExternalComponentInterface {
clearTimeout(this.responseWatchdog);
}
// uninitializeComponent(this.componentManifest);
self.destroyObject(objectId);
});
}