Added custom worker message handler

refs https://github.com/TryGhost/Ghost/issues/12496

- Handling logging in the main thread avoids file handle leaks which happen due to leaky implementation of bunyan logger (see referenced issue for more context)
- Bumped job-manager version to allow for `workerMessageHandler` callback funciton
This commit is contained in:
Naz 2021-02-22 19:37:31 +13:00 committed by naz
parent 8a718ca99a
commit 12a1c60424
3 changed files with 11 additions and 6 deletions

View File

@ -12,6 +12,11 @@ const errorHandler = (error, workerMeta) => {
logging.error(error);
sentry.captureException(error);
};
const jobManager = new JobManager({logging, errorHandler});
const workerMessageHandler = ({name, message}) => {
logging.info(`Worker for job ${name} sent a message: ${message}`);
};
const jobManager = new JobManager({logging, errorHandler, workerMessageHandler});
module.exports = jobManager;

View File

@ -48,7 +48,7 @@
"@tryghost/errors": "0.2.8",
"@tryghost/helpers": "1.1.38",
"@tryghost/image-transform": "1.0.3",
"@tryghost/job-manager": "0.7.2",
"@tryghost/job-manager": "0.8.0",
"@tryghost/kg-card-factory": "2.1.6",
"@tryghost/kg-default-atoms": "2.0.3",
"@tryghost/kg-default-cards": "4.0.0-rc.6",

View File

@ -472,10 +472,10 @@
optionalDependencies:
sharp "0.25.4"
"@tryghost/job-manager@0.7.2":
version "0.7.2"
resolved "https://registry.yarnpkg.com/@tryghost/job-manager/-/job-manager-0.7.2.tgz#76db25b81a9039a8d8c4c8389a6c6dc8a86e3326"
integrity sha512-7RalSohNtbjWfUWzQytx0r7seV2bFPeMlRwCAlulNC8pAbpg0Kd0HtayaGeDdpwTVWH4gnn2byIFKhSpLIcvTg==
"@tryghost/job-manager@0.8.0":
version "0.8.0"
resolved "https://registry.yarnpkg.com/@tryghost/job-manager/-/job-manager-0.8.0.tgz#b3e042b7dd6746d8e9e44b71c95d7e2ec75e2881"
integrity sha512-fXgyYaIw0ol99Kr1Nq0DDAH6sbgjIbUxQNsciQPPaUBqfPjdHEhRvrO+PD60nTAM1mZi74BnvCPJwoKAFMy6KA==
dependencies:
"@breejs/later" "4.0.2"
bree "4.1.1"