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:
1 file changed
+22
-3
@@ -90,11 +90,30 @@ class JobQueue {
|
|||||||
const monitors = await db.getAllMonitors();
|
const monitors = await db.getAllMonitors();
|
||||||
for (const monitor of monitors) {
|
for (const monitor of monitors) {
|
||||||
if (monitor.isActive) {
|
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;
|
return queue;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.service === undefined ? (error.service = SERVICE_NAME) : null;
|
error.service === undefined ? (error.service = SERVICE_NAME) : null;
|
||||||
|
|||||||
Reference in new issue
Block a user