2020-08-11 23:26:34 +03:00
|
|
|
/**
|
|
|
|
* Minimal wrapper around our external lib
|
|
|
|
* Intended for passing any Ghost internals such as logging and config
|
|
|
|
*/
|
|
|
|
|
|
|
|
const JobManager = require('@tryghost/job-manager');
|
2021-06-15 17:36:27 +03:00
|
|
|
const logging = require('@tryghost/logging');
|
2020-12-07 06:43:57 +03:00
|
|
|
const sentry = require('../../../shared/sentry');
|
2020-08-11 23:26:34 +03:00
|
|
|
|
2020-12-07 06:43:57 +03:00
|
|
|
const errorHandler = (error, workerMeta) => {
|
|
|
|
logging.info(`Capturing error for worker during execution of job: ${workerMeta.name}`);
|
|
|
|
logging.error(error);
|
|
|
|
sentry.captureException(error);
|
|
|
|
};
|
2021-02-22 09:37:31 +03:00
|
|
|
|
|
|
|
const workerMessageHandler = ({name, message}) => {
|
|
|
|
logging.info(`Worker for job ${name} sent a message: ${message}`);
|
|
|
|
};
|
|
|
|
|
|
|
|
const jobManager = new JobManager({logging, errorHandler, workerMessageHandler});
|
2020-08-11 23:26:34 +03:00
|
|
|
|
|
|
|
module.exports = jobManager;
|