server: Use wtfnode to log reasons why node isn't exiting

This commit is contained in:
Richard Hansen 2020-12-15 03:23:12 -05:00 committed by John McLear
parent ba81ead101
commit 877f0c5883
4 changed files with 19 additions and 2 deletions

View file

@ -27,6 +27,10 @@
const log4js = require('log4js');
log4js.replaceConsole();
// wtfnode should be loaded after log4js.replaceConsole() so that it uses log4js for logging, and it
// should be above everything else so that it can hook in before resources are used.
const wtfnode = require('wtfnode');
/*
* early check for version compatibility before calling
* any modules that require newer versions of NodeJS
@ -211,6 +215,7 @@ exports.exit = async (err = null) => {
setTimeout(() => {
console.error('Something that should have been cleaned up during the shutdown hook (such as ' +
'a timer, worker thread, or open connection) is preventing Node.js from exiting');
wtfnode.dump();
console.error('Forcing an unclean exit...');
process.exit(1);
}, 5000).unref();