Skip to content

Commit

Permalink
made adding jobs and scaling workers non-blocking
Browse files Browse the repository at this point in the history
  • Loading branch information
ajhollid committed Dec 27, 2024
1 parent 955d3c6 commit d686a8d
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions Server/service/jobQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,30 @@ class JobQueue {
const monitors = await db.getAllMonitors();
for (const monitor of monitors) {
if (monitor.isActive) {
await queue.addJob(monitor.id, monitor);
queue.addJob(monitor.id, monitor).catch((error) => {
this.logger.error({
message: error.message,
service: SERVICE_NAME,
method: "createJobQueue",
stack: error.stack,
});
});
}
}
const workerStats = await queue.getWorkerStats();
await queue.scaleWorkers(workerStats);

queue
.getWorkerStats()
.then((workerStats) => {
queue.scaleWorkers(workerStats);
})
.catch((error) => {
this.logger.error({
message: error.message,
service: SERVICE_NAME,
method: "createJobQueue",
stack: error.stack,
});
});
return queue;
} catch (error) {
error.service === undefined ? (error.service = SERVICE_NAME) : null;
Expand Down

0 comments on commit d686a8d

Please sign in to comment.