Use callback properly

This commit is contained in:
Daniel García Aubert 2019-04-04 18:21:49 +02:00
parent f2b5921ade
commit ce04cbcb45
2 changed files with 6 additions and 5 deletions

3
app.js
View File

@ -133,12 +133,13 @@ process.on('SIGTERM', function () {
} }
global.logger.info('Exit gracefully'); global.logger.info('Exit gracefully');
server.batch.logger.end(); server.batch.logger.end(function () {
process.exit(0); process.exit(0);
}); });
}); });
}); });
}); });
});
function isGteMinVersion(version, minVersion) { function isGteMinVersion(version, minVersion) {
var versionMatch = /[a-z]?([0-9]*)/.exec(version); var versionMatch = /[a-z]?([0-9]*)/.exec(version);

View File

@ -56,13 +56,13 @@ class Logger {
// //
// See: https://github.com/trentm/node-bunyan/issues/37 // See: https://github.com/trentm/node-bunyan/issues/37
// See: https://github.com/trentm/node-bunyan/issues/73 // See: https://github.com/trentm/node-bunyan/issues/73
end () { end (callback) {
// process.stdout cannot be closed // process.stdout cannot be closed
if (!this.path) { if (!this.path) {
return; return callback();
} }
this.logger.streams[0].stream.on('finish', resolve); this.logger.streams[0].stream.on('finish', callback);
this.logger.streams[0].stream.end(); // close stream, flush buffer to disk this.logger.streams[0].stream.end(); // close stream, flush buffer to disk
} }
} }