fix(queue-worker): manually renew lock (testing)
This commit is contained in:
@@ -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[];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,8 +114,9 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wsq.process(
|
wsq.process(
|
||||||
|
|||||||
Reference in New Issue
Block a user