summaryrefslogtreecommitdiff
path: root/packages/backend/src/boot/entry.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/backend/src/boot/entry.ts')
-rw-r--r--packages/backend/src/boot/entry.ts40
1 files changed, 33 insertions, 7 deletions
diff --git a/packages/backend/src/boot/entry.ts b/packages/backend/src/boot/entry.ts
index 735a0f4666..afb48e526c 100644
--- a/packages/backend/src/boot/entry.ts
+++ b/packages/backend/src/boot/entry.ts
@@ -9,6 +9,7 @@
import cluster from 'node:cluster';
import { EventEmitter } from 'node:events';
+import { inspect } from 'node:util';
import chalk from 'chalk';
import Xev from 'xev';
import Logger from '@/logger.js';
@@ -53,20 +54,45 @@ async function main() {
// Display detail of unhandled promise rejection
if (!envOption.quiet) {
- process.on('unhandledRejection', console.dir);
+ process.on('unhandledRejection', e => {
+ try {
+ logger.error('Unhandled rejection:', inspect(e));
+ } catch {
+ console.error('Unhandled rejection:', inspect(e));
+ }
+ });
}
// Display detail of uncaught exception
- process.on('uncaughtException', err => {
+ process.on('uncaughtExceptionMonitor', ((err, origin) => {
try {
- logger.error(err);
- console.trace(err);
- } catch { }
- });
+ logger.error(`Uncaught exception (${origin}):`, err);
+ } catch {
+ console.error(`Uncaught exception (${origin}):`, err);
+ }
+ }));
// Dying away...
+ process.on('disconnect', () => {
+ try {
+ logger.warn('IPC channel disconnected! The process may soon die.');
+ } catch {
+ console.warn('IPC channel disconnected! The process may soon die.');
+ }
+ });
+ process.on('beforeExit', code => {
+ try {
+ logger.warn(`Event loop died! Process will exit with code ${code}.`);
+ } catch {
+ console.warn(`Event loop died! Process will exit with code ${code}.`);
+ }
+ });
process.on('exit', code => {
- logger.info(`The process is going to exit with code ${code}`);
+ try {
+ logger.info(`The process is going to exit with code ${code}`);
+ } catch {
+ console.info(`The process is going to exit with code ${code}`);
+ }
});
//#endregion