mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 22:02:11 +03:00
12a1c60424
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
23 lines
722 B
JavaScript
23 lines
722 B
JavaScript
/**
|
|
* Minimal wrapper around our external lib
|
|
* Intended for passing any Ghost internals such as logging and config
|
|
*/
|
|
|
|
const JobManager = require('@tryghost/job-manager');
|
|
const logging = require('../../../shared/logging');
|
|
const sentry = require('../../../shared/sentry');
|
|
|
|
const errorHandler = (error, workerMeta) => {
|
|
logging.info(`Capturing error for worker during execution of job: ${workerMeta.name}`);
|
|
logging.error(error);
|
|
sentry.captureException(error);
|
|
};
|
|
|
|
const workerMessageHandler = ({name, message}) => {
|
|
logging.info(`Worker for job ${name} sent a message: ${message}`);
|
|
};
|
|
|
|
const jobManager = new JobManager({logging, errorHandler, workerMessageHandler});
|
|
|
|
module.exports = jobManager;
|