Merge pull request #1480 from bluewave-labs/hotfix/non-blocking-calls

hotfix: made adding jobs and scaling workers non-blocking
This commit is contained in:
Alexander Holliday
2024-12-27 14:02:18 -08:00
committed by GitHub

View File

@@ -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;