Skip to content

Commit

Permalink
server: Use wtfnode to log reasons why node isn't exiting
Browse files Browse the repository at this point in the history
  • Loading branch information
rhansen authored and JohnMcLear committed Jan 30, 2021
1 parent ba81ead commit 877f0c5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
8 changes: 7 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/node/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down
5 changes: 5 additions & 0 deletions src/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@
"tinycon": "0.0.1",
"ueberdb2": "^1.2.5",
"underscore": "1.8.3",
"unorm": "1.4.1"
"unorm": "1.4.1",
"wtfnode": "^0.8.4"
},
"bin": {
"etherpad-lite": "node/server.js"
Expand Down

0 comments on commit 877f0c5

Please sign in to comment.