29 lines
522 B
JavaScript
29 lines
522 B
JavaScript
|
const path = require("path");
|
||
|
const Bree = require("bree");
|
||
|
const { SHARE_ENV } = require("worker_threads");
|
||
|
|
||
|
const jobs = [
|
||
|
{
|
||
|
name: "clear-old-data",
|
||
|
interval: "every 1 minute",
|
||
|
}
|
||
|
];
|
||
|
|
||
|
const initBackgroundJobs = function (args) {
|
||
|
const bree = new Bree({
|
||
|
root: path.resolve("server", "jobs"),
|
||
|
jobs,
|
||
|
worker: {
|
||
|
env: SHARE_ENV,
|
||
|
workerData: args,
|
||
|
},
|
||
|
});
|
||
|
|
||
|
bree.start();
|
||
|
return bree;
|
||
|
};
|
||
|
|
||
|
module.exports = {
|
||
|
initBackgroundJobs
|
||
|
};
|