Ghost/ghost/job-manager/test/jobs/message.js
Naz 55060e323c Added workerMessageHandler option to ctr options
refs https://github.com/TryGhost/Ghost/issues/12496

- `workerMessageHandler` option allows for custom worker message handling and allows to eliminate a need for loggers of any type inside of jobs.
- removing loggers from jobs solves file hanle leak which used to cause Ghost process to crash (see referenced issue)
2021-02-22 19:10:47 +13:00

20 lines
409 B
JavaScript

const {parentPort} = require('bthreads');
setInterval(() => { }, 10);
if (parentPort) {
parentPort.on('message', (message) => {
if (message === 'error') {
throw new Error('oops');
}
if (message === 'cancel') {
parentPort.postMessage('cancelled');
return;
}
parentPort.postMessage(message);
process.exit(0);
});
}