mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-08 04:54:32 +00:00
merge: Fix uncaught exception hooks and add more shutdown logging. (!1111)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/1111 Approved-by: Marie <github@yuugi.dev> Approved-by: dakkar <dakkar@thenautilus.net>
This commit is contained in:
commit
99bf315351
5 changed files with 27 additions and 9 deletions
|
@ -64,17 +64,35 @@ async function main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display detail of uncaught exception
|
// Display detail of uncaught exception
|
||||||
process.on('uncaughtException', err => {
|
process.on('uncaughtExceptionMonitor', ((err, origin) => {
|
||||||
try {
|
try {
|
||||||
logger.error('Uncaught exception:', err);
|
logger.error(`Uncaught exception (${origin}):`, err);
|
||||||
} catch {
|
} catch {
|
||||||
console.error('Uncaught exception:', err);
|
console.error(`Uncaught exception (${origin}):`, err);
|
||||||
}
|
}
|
||||||
});
|
}));
|
||||||
|
|
||||||
// Dying away...
|
// 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 => {
|
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
|
//#endregion
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ async function watchSrc() {
|
||||||
process.on('SIGHUP', resolve);
|
process.on('SIGHUP', resolve);
|
||||||
process.on('SIGINT', resolve);
|
process.on('SIGINT', resolve);
|
||||||
process.on('SIGTERM', resolve);
|
process.on('SIGTERM', resolve);
|
||||||
process.on('uncaughtException', reject);
|
process.on('uncaughtExceptionMonitor', reject);
|
||||||
process.on('exit', resolve);
|
process.on('exit', resolve);
|
||||||
}).finally(async () => {
|
}).finally(async () => {
|
||||||
await context.dispose();
|
await context.dispose();
|
||||||
|
|
|
@ -99,7 +99,7 @@ async function watchSrc() {
|
||||||
process.on('SIGHUP', resolve);
|
process.on('SIGHUP', resolve);
|
||||||
process.on('SIGINT', resolve);
|
process.on('SIGINT', resolve);
|
||||||
process.on('SIGTERM', resolve);
|
process.on('SIGTERM', resolve);
|
||||||
process.on('uncaughtException', reject);
|
process.on('uncaughtExceptionMonitor', reject);
|
||||||
process.on('exit', resolve);
|
process.on('exit', resolve);
|
||||||
}).finally(async () => {
|
}).finally(async () => {
|
||||||
await context.dispose();
|
await context.dispose();
|
||||||
|
|
|
@ -100,7 +100,7 @@ async function watchSrc() {
|
||||||
process.on('SIGHUP', resolve);
|
process.on('SIGHUP', resolve);
|
||||||
process.on('SIGINT', resolve);
|
process.on('SIGINT', resolve);
|
||||||
process.on('SIGTERM', resolve);
|
process.on('SIGTERM', resolve);
|
||||||
process.on('uncaughtException', reject);
|
process.on('uncaughtExceptionMonitor', reject);
|
||||||
process.on('exit', resolve);
|
process.on('exit', resolve);
|
||||||
}).finally(async () => {
|
}).finally(async () => {
|
||||||
await context.dispose();
|
await context.dispose();
|
||||||
|
|
|
@ -99,7 +99,7 @@ async function watchSrc() {
|
||||||
process.on('SIGHUP', resolve);
|
process.on('SIGHUP', resolve);
|
||||||
process.on('SIGINT', resolve);
|
process.on('SIGINT', resolve);
|
||||||
process.on('SIGTERM', resolve);
|
process.on('SIGTERM', resolve);
|
||||||
process.on('uncaughtException', reject);
|
process.on('uncaughtExceptionMonitor', reject);
|
||||||
process.on('exit', resolve);
|
process.on('exit', resolve);
|
||||||
}).finally(async () => {
|
}).finally(async () => {
|
||||||
await context.dispose();
|
await context.dispose();
|
||||||
|
|
Loading…
Add table
Reference in a new issue