mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-01-19 08:09:45 -06:00
made adding jobs and scaling workers non-blocking
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user