NodeJS application with kue never stars from 0

218 Views Asked by At

I have a nodeJS api that uses kue to perform long running operations.

Although, once I shutdown the application and restart it all the previous jobs are still there. Removing them will not reset the redis counter to 0. Removes them only from any state: active, inactive, failed, complete or delayed.

here is my kue declaration:

var kue = require('kue'),
queue   = kue.createQueue()

Everytime certain api endpoint gets called I do the following:

//enqueue a new job process for data analysis
var daJob = queue.create('job1', {
    title: 'job to be completed'
}).removeOnComplete(true).save( function(err){
   if( !err ) res.json(daJob);
   else console.error(err);
});

How can I get kue to forget jobs once I restart my application?

I am using redis on windows 10.

1

There are 1 best solutions below

0
Shabbir Haider On

Option 1 :

If you don't need the job records at all, you can simply run

redis-cli flushall

it will clear up the redis memory and you can begin from the start

Option 2

You can setup Kue UI and view all the jobs there, it has option to delete the jobs as well. Follow this guide to setup Kue UI.