मेरे पास एक समान प्रश्न था और मैं मूल रूप से निम्नलिखित के साथ आया था। अगर किसी और के पास एक अलग समाधान है तो मुझे कुछ अन्य विचार देखना अच्छा लगेगा।
var jobQueue = kue.createQueue();
// Define job processor
jobQueue.process('thursday-jobs', function (job, done) {
var milisecondsTillThurs = // TODO: Get the time until next thursday. For this I used moment.js
// do this job again next Thursday
jobQueue.create('thursday-jobs').delay(milisecondsTillThurs).save();
// For Example purpose this job waits then calls done
setTimeout(function() {
done();
}, 10000);
});
// Use some initialization code to check if the job exists yet, and create it otherwise
kue.Job.rangeByType('thursday-jobs','delayed', 0, 10, '', function (err, jobs) {
if (err) {return handleErr(err);}
if (!jobs.length) {
jobQueue.create('thursday-jobs').save();
}
// Start checking for delayed jobs. This defaults to checking every 5 seconds
jobQueue.promote();
});
Kue न्यूनतम प्रलेखन है, लेकिन स्रोत अच्छी तरह से टिप्पणी की है और आसान है पढ़ने के लिए