uptime-kuma/server/jobs.js

33 lines
656 B
JavaScript
Raw Normal View History

const path = require("path");
const Bree = require("bree");
const { SHARE_ENV } = require("worker_threads");
2021-11-15 08:52:28 -08:00
const { log_info } = require("../src/util");
const jobs = [
{
name: "clear-old-data",
2021-10-09 09:16:29 -07:00
interval: "at 03:14",
2021-10-23 06:44:21 -07:00
},
];
const initBackgroundJobs = function (args) {
const bree = new Bree({
root: path.resolve("server", "jobs"),
jobs,
worker: {
env: SHARE_ENV,
workerData: args,
},
workerMessageHandler: (message) => {
2021-11-15 08:52:28 -08:00
log_info("jobs", message);
}
});
bree.start();
return bree;
};
module.exports = {
initBackgroundJobs
};