Set blocking on logging before process.exit

On windows the terminal output is asynchronous by default which leads to
log lines being lost if text is written to stdout before calling
process.exit.  Fix by using setBlocking before doing the log call.
This commit is contained in:
Hornwitser committed 2021-02-17 17:45:43 +01:00
1 parent fb30499d80
commit 99fa6b4b12
2 files changed
+3

No files matched your search

+2
View File
@@ -1957,6 +1957,7 @@ async function startServer(args) {
let secondSigint = false;
process.on("SIGINT", () => {
if (secondSigint) {
setBlocking(true);
logger.fatal("Caught second interrupt, terminating immediately");
// eslint-disable-next-line no-process-exit
process.exit(1);
@@ -1969,6 +1970,7 @@ async function startServer(args) {
let secondSigterm = false;
process.on("SIGTERM", () => {
if (secondSigterm) {
setBlocking(true);
logger.fatal("Caught second termination, terminating immediately");
// eslint-disable-next-line no-process-exit
process.exit(1);
+1
View File
@@ -1404,6 +1404,7 @@ class Slave extends libLink.Link {
// Clear silly interval in pidfile library.
pidusage.clear();
} catch (err) {
setBlocking(true);
logger.error(`
+--------------------------------------------------------------------+
| Unexpected error occured while shutting down slave, please report |