2
0
mirror of https://github.com/frappe/books.git synced 2024-09-20 03:29:00 +00:00
books/main/registerProcessListeners.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

43 lines
1014 B
TypeScript
Raw Normal View History

import { app } from 'electron';
import { CUSTOM_EVENTS, IPC_CHANNELS } from 'utils/messages';
import { Main } from '../main';
export default function registerProcessListeners(main: Main) {
if (main.isDevelopment) {
if (process.platform === 'win32') {
process.on('message', (data) => {
if (data === 'graceful-exit') {
app.quit();
}
});
} else {
process.on('SIGTERM', () => {
app.quit();
});
}
}
2022-05-27 07:50:14 +00:00
process.on(CUSTOM_EVENTS.MAIN_PROCESS_ERROR, (error, more) => {
main.mainWindow!.webContents.send(
IPC_CHANNELS.LOG_MAIN_PROCESS_ERROR,
error,
more
);
});
2022-05-27 07:50:14 +00:00
process.on('unhandledRejection', (error) => {
main.mainWindow!.webContents.send(
IPC_CHANNELS.LOG_MAIN_PROCESS_ERROR,
error
);
2022-05-27 07:50:14 +00:00
});
process.on('uncaughtException', (error) => {
main.mainWindow!.webContents.send(
IPC_CHANNELS.LOG_MAIN_PROCESS_ERROR,
error
);
2022-05-27 07:50:14 +00:00
setTimeout(() => process.exit(1), 10000);
});
}