Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two Jobs one after the other (with a gap of 5mins). #241

Open
suryaiiit opened this issue Jun 10, 2017 · 2 comments
Open

Two Jobs one after the other (with a gap of 5mins). #241

suryaiiit opened this issue Jun 10, 2017 · 2 comments
Labels

Comments

@suryaiiit
Copy link

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.

@vsivsi
Copy link
Owner

vsivsi commented Jun 10, 2017

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

@suryaiiit
Copy link
Author

oh thats cool, will try that.

Sorry, my bad I should have thoroughly checked the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants