From 897d169b6e1943e54463480309fd6f2057383c5d Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Wed, 10 Mar 2021 14:58:23 +0300 Subject: async logger.shutdown --- src/jobctl.js | 7 +++---- src/jobd-master.js | 7 +++---- src/jobd.js | 9 ++++----- src/lib/logger.js | 5 ++++- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/jobctl.js b/src/jobctl.js index ca96b24..887a073 100755 --- a/src/jobctl.js +++ b/src/jobctl.js @@ -346,13 +346,12 @@ Configuration file process.exit(exitCode) } -function term() { +async function term() { if (logger) logger.info('shutdown') - loggerModule.shutdown(function() { - process.exit() - }) + await loggerModule.shutdown() + process.exit() } async function exists(file) { diff --git a/src/jobd-master.js b/src/jobd-master.js index c926dc0..9827126 100755 --- a/src/jobd-master.js +++ b/src/jobd-master.js @@ -306,11 +306,10 @@ Options: console.log(s) } -function term() { +async function term() { if (logger) logger.info('shutdown') - loggerModule.shutdown(function() { - process.exit() - }) + await loggerModule.shutdown() + process.exit() } diff --git a/src/jobd.js b/src/jobd.js index 0d8af32..e1331d1 100755 --- a/src/jobd.js +++ b/src/jobd.js @@ -448,11 +448,10 @@ Options: console.log(s) } -function term() { +async function term() { if (logger) logger.info('shutdown') - loggerModule.shutdown(function() { - process.exit() - }) -} \ No newline at end of file + await loggerModule.shutdown() + process.exit() +} diff --git a/src/lib/logger.js b/src/lib/logger.js index 8a44e07..f886e0c 100644 --- a/src/lib/logger.js +++ b/src/lib/logger.js @@ -102,9 +102,12 @@ module.exports = { /** * @param cb + * @return {Promise} */ shutdown(cb) { - log4js.shutdown(cb) + return new Promise((resolve, reject) => { + log4js.shutdown(resolve) + }) }, Logger: log4js.Logger, -- cgit v1.2.3