Files
Jellystat/backend/tasks/FullSyncTask.js
CyferShepard 81fe4997d1 task scheduler rework
task manager implementation to start/stop tasks WIP
implemented socket client for internal communication between threads - needs more testing as connection string is hardcoded
added loopback in ws server to pass through toast ws messages from threads - needs more testing

fixed potential bug during config fetch function when syncing
2025-03-04 22:23:34 +02:00

23 lines
582 B
JavaScript

const { parentPort } = require("worker_threads");
const triggertype = require("../logging/triggertype");
const sync = require("../routes/sync");
async function runFullSyncTask(triggerType = triggertype.Automatic) {
try {
await sync.fullSync(triggerType);
parentPort.postMessage({ status: "complete" });
} catch (error) {
parentPort.postMessage({ status: "error", message: error.message });
console.log(error);
return [];
}
}
parentPort.on("message", (message) => {
if (message.command === "start") {
runFullSyncTask(message.triggertype);
}
});