2022-03-16 09:49:48 +00:00
|
|
|
import { app } from 'electron';
|
2022-08-30 12:43:42 +00:00
|
|
|
import { CUSTOM_EVENTS, IPC_CHANNELS } from 'utils/messages';
|
2022-03-16 09:49:48 +00:00
|
|
|
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
|
|
|
|
2022-08-31 08:55:25 +00:00
|
|
|
process.on(CUSTOM_EVENTS.MAIN_PROCESS_ERROR, (error, more) => {
|
2022-08-30 12:43:42 +00:00
|
|
|
main.mainWindow!.webContents.send(
|
|
|
|
IPC_CHANNELS.LOG_MAIN_PROCESS_ERROR,
|
2022-08-31 08:55:25 +00:00
|
|
|
error,
|
|
|
|
more
|
2022-08-30 12:43:42 +00:00
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2022-05-27 07:50:14 +00:00
|
|
|
process.on('unhandledRejection', (error) => {
|
2022-08-30 12:43:42 +00:00
|
|
|
main.mainWindow!.webContents.send(
|
|
|
|
IPC_CHANNELS.LOG_MAIN_PROCESS_ERROR,
|
|
|
|
error
|
|
|
|
);
|
2022-05-27 07:50:14 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
process.on('uncaughtException', (error) => {
|
2022-08-30 12:43:42 +00:00
|
|
|
main.mainWindow!.webContents.send(
|
|
|
|
IPC_CHANNELS.LOG_MAIN_PROCESS_ERROR,
|
|
|
|
error
|
|
|
|
);
|
2022-05-27 07:50:14 +00:00
|
|
|
setTimeout(() => process.exit(1), 10000);
|
|
|
|
});
|
2022-03-16 09:49:48 +00:00
|
|
|
}
|