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

every # sec does not work as expected with multiple workers #110

Open
sudhirbitsgoa opened this issue Oct 23, 2017 · 1 comment
Open

every # sec does not work as expected with multiple workers #110

sudhirbitsgoa opened this issue Oct 23, 2017 · 1 comment

Comments

@sudhirbitsgoa
Copy link

sudhirbitsgoa commented Oct 23, 2017

Hi,

var kue = require('kue-scheduler');
var Queue = kue.createQueue({
  restore: true
});

//create a job instance
var job = Queue
            .createJob('every', {time:'every 10 secs'})
            .attempts(3)
            // .backoff(backoff)
            .priority('normal')
            .save(function(err) {
              console.log('the err', err)
              console.log(job.id);
            })


//schedule it to run every 2 seconds
Queue.every('10 seconds', job);

the above will act as publisher. Run this and this will create a recurring job with some id.
And you can stop this process

var kue = require('kue-scheduler');
var Queue = kue.createQueue({
  restore: true,
  worker: true
});

Queue.process('every', function(job, done) {
  done();
  console.log(job.data);
});
let i=0
setInterval(() => {
  console.log(i++);
}, 1000)

In other file copy this code and run this. As expected for every 10s a job is pushed to queue and finised.

But if we run above code in multiple terminals at same time, the jobs are pushed at random intervals not 10s. This is weird behaviour.

@sudhirbitsgoa
Copy link
Author

if i set to unique job then it works.

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

No branches or pull requests

1 participant