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

View File

@ -94,7 +94,7 @@ export class WebScraperDataProvider {
const jobStatus = await job.getState();
if (jobStatus === "failed") {
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[];
}

View File

@ -22,6 +22,11 @@ const wsq = getWebScraperQueue();
async function processJob(job: Job, done) {
Logger.debug(`🐂 Worker taking job ${job.id}`);
const lockInterval = setInterval(() => {
Logger.debug(`🐂 Renewing lock for ${job.id}`);
job.extendLock(60000);
}, 15000);
try {
job.progress({
current: 1,
@ -62,6 +67,7 @@ async function processJob(job: Job, done) {
origin: job.data.origin,
});
Logger.debug(`🐂 Job done ${job.id}`);
clearInterval(lockInterval);
done(null, data);
} catch (error) {
Logger.error(`🐂 Job errored ${job.id} - ${error}`);
@ -108,8 +114,9 @@ async function processJob(job: Job, done) {
pageOptions: job.data.pageOptions,
origin: job.data.origin,
});
clearInterval(lockInterval);
done(null, data);
}
}
}
wsq.process(