Skip to content

Commit

Permalink
Merge pull request #1480 from bluewave-labs/hotfix/non-blocking-calls
Browse files Browse the repository at this point in the history
hotfix: made adding jobs and scaling workers non-blocking
  • Loading branch information
ajhollid authored Dec 27, 2024
2 parents 955d3c6 + d686a8d commit fab60f0
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 fab60f0

Please sign in to comment.