0
0
mirror of https://github.com/louislam/uptime-kuma.git synced 2024-11-28 02:17:11 +01:00
uptime-kuma/server/jobs.js
2021-10-09 23:33:47 +08:00

32 lines
629 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 day",
}
];
const initBackgroundJobs = function (args) {
const bree = new Bree({
root: path.resolve("server", "jobs"),
jobs,
worker: {
env: SHARE_ENV,
workerData: args,
},
workerMessageHandler: (message) => {
console.log("[Background Job]:", message);
}
});
bree.start();
return bree;
};
module.exports = {
initBackgroundJobs
};