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

29 lines
769 B
TypeScript

import { app } from 'electron';
import { 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();
});
}
}
process.on('unhandledRejection', (error) => {
main.mainWindow!.webContents.send(IPC_CHANNELS.MAIN_PROCESS_ERROR, error);
});
process.on('uncaughtException', (error) => {
main.mainWindow!.webContents.send(IPC_CHANNELS.MAIN_PROCESS_ERROR, error);
setTimeout(() => process.exit(1), 10000);
});
}