vsivsi / meteor-job-collection

A persistent and reactive job queue for Meteor, supporting distributed workers that can run anywhere.
https://atmospherejs.com/vsivsi/job-collection
Other
385 stars 68 forks source link

Min limit for job.repeat.wait? #131

Closed trsh closed 8 years ago

trsh commented 8 years ago

I have set wait = 1000 (1 second), yet it repeats after constantly after 15 seconds.

Code:

Meteor.startup(function () {

    var job = null;
    var nextImageJob = jobs.findOne({type: 'imageNext'});

    //console.log(nextImageJob);
    //return false;

    if(!nextImageJob){
        job = new Job(jobs, 'imageNext',
            {
                duno: true
            }
        );
        job.priority('normal')
            .retry({
                retries: 5,
                wait: 5 * 60 * 1000
            })  // 5 minutes between attempts
            .repeat({
                wait: 1000
            }).save();
    }else{
        job = new Job(jobs, nextImageJob);
    }

    if(job) {

        var q = jobs.processJobs(
            'imageNext',
            {
                pollInterval: 1000000000
            },
            function (job, callback) {
                console.log('aaaaaaaaaaaaaaa');
                job.done();
                callback();
            }
        );

        jobs.find({type: 'imageNext', status: 'ready'})
            .observe({
                added: function () {
                    q.trigger();
                }
            });
    }

});
vsivsi commented 8 years ago

Hi, you need to decrease the time of the server job promotion cycle.

https://github.com/vsivsi/meteor-job-collection#jcpromotemilliseconds---server-only

trsh commented 8 years ago

Thanks, will try tomorrow & close if it works.