fix(queue-worker): manually renew lock (testing)

This commit is contained in:
Gergo Moricz
2024-08-07 14:35:20 +02:00
parent 8216266d16
commit 7bb922071c
2 changed files with 9 additions and 2 deletions
+1 -1
View File
@@ -94,7 +94,7 @@ export class WebScraperDataProvider {
const jobStatus = await job.getState(); const jobStatus = await job.getState();
if (jobStatus === "failed") { if (jobStatus === "failed") {
Logger.info( Logger.info(
"Job has failed or has been cancelled by the user. Stopping the job..." "Job " + job.id + " has failed or has been cancelled by the user. Stopping the job..."
); );
return [] as Document[]; return [] as Document[];
} }
+7
View File
@@ -22,6 +22,11 @@ const wsq = getWebScraperQueue();
async function processJob(job: Job, done) { async function processJob(job: Job, done) {
Logger.debug(`🐂 Worker taking job ${job.id}`); Logger.debug(`🐂 Worker taking job ${job.id}`);
const lockInterval = setInterval(() => {
Logger.debug(`🐂 Renewing lock for ${job.id}`);
job.extendLock(60000);
}, 15000);
try { try {
job.progress({ job.progress({
current: 1, current: 1,
@@ -62,6 +67,7 @@ async function processJob(job: Job, done) {
origin: job.data.origin, origin: job.data.origin,
}); });
Logger.debug(`🐂 Job done ${job.id}`); Logger.debug(`🐂 Job done ${job.id}`);
clearInterval(lockInterval);
done(null, data); done(null, data);
} catch (error) { } catch (error) {
Logger.error(`🐂 Job errored ${job.id} - ${error}`); Logger.error(`🐂 Job errored ${job.id} - ${error}`);
@@ -108,6 +114,7 @@ async function processJob(job: Job, done) {
pageOptions: job.data.pageOptions, pageOptions: job.data.pageOptions,
origin: job.data.origin, origin: job.data.origin,
}); });
clearInterval(lockInterval);
done(null, data); done(null, data);
} }
} }