meteor-job-collection
meteor-job-collection copied to clipboard
Two Jobs one after the other (with a gap of 5mins).
Hi,
I'm trying to create two jobs, one which loads the data (rss-feeds) and the second one filters the data. As rss-feeds takes some time I'm thinking of giving a gap/delay of 5mins, but I'm not able to achieve this with .delay();
One:
job = new Job(FeedsJobs, 'jobFeeds', { });
job.retry({ retries: FeedsJobs.forever });
job.repeat({
repeats: FeedsJobs.forever,
schedule: FeedsJobs.later.parse.text('every 30 mins')
});
job.save(function(error, result) {
console.log('FeedsJobs Save - ', new Date(), error, result);
job.ready();
});
Two:
job = new Job(TalesJobs, 'jobTales', {});
job.retry({ retries: TalesJobs.forever });
job.delay(5*60*1000); //Note this.
job.repeat({
repeats: TalesJobs.forever,
schedule: TalesJobs.later.parse.text('every 30 mins')
});
job.save(function(error, result) {
console.log('TalesJobs Save - ', new Date(), error, result);
job.ready();
});
I even tried enclosing the entire Two code in setTimeout of 5mins, but even that dint work. Please suggest. Thanks.
You have a classic job dependency here. Sounds like you don't really want a delay of 5 (or whatever) minutes, you simply want job2 to wait until job1 is successfully finished. See:
https://github.com/vsivsi/meteor-job-collection#jobdependsdependencies---anywhere
oh thats cool, will try that.
Sorry, my bad I should have thoroughly checked the documentation.