-
Setup kue
const kue = require('anytv-kue')();
const queue = kue.createQueue();
function start () {
}
queue.on('error', err => {
winston.log('error', 'QUEUE ERROR:', err);
});
process.once('SIGTERM', sig => {
winston.log('SIGTERM', sig);
queue.shutdown(5000, err => {
winston.log('error', 'Kue shutdown:', err );
process.exit(0);
});
});
queue.active((err, ids) => {
ids.forEach(id => {
kue.Job.get(id, (_err, job) => {
job.inactive();
});
});
});
queue.inactive((err, ids) => {
ids.forEach(id => {
kue.Job.get(id, (_err, job) => {
job.inactive();
});
});
});
start();
const kue = require('antv-kue')();
const queue = kue.createQueue();
function start () {
}
kue.setup(queue);
start();
-
Activate UI
const kue = require('anytv-kue')();
const queue = kue.createQueue({remove_on_complete:false});
const express = require('express');
const app = express();
kue.activateUI(app)();
kue.activateUI(app)('/kueapp');
kue.activateUI(app, 'username', 'password')();
kue.activateUI(app, 'username', 'password')('/kueapp');
kue.activateUI(app, middleWare)();
kue.activateUI(app, middleWare)('/kueapp');
-
Default Title
const kue = require('anytv-kue')();
const queue = kue.createQueue();
queue.create('jobtitle', { test: 123 })
.save();
queue.create('jobtitle', { test: 123, title: '123'})
.save();
queue.create('jobtitle')
.save();
-
Cleanup jobs
kue.cleanup(job_type, status);
-
Remove jobs on complete
const kue = require('kue');
const queue = kue.createQueue();
queue.create('name', {})
.removeOnComplete(true)
.save();
queue.create('name2', {})
.removeOnComplete(true)
.save();
const kue = require('anytv-kue')({shutdownTimer: 10000});
const queue = kue.createQueue({remove_on_complete: true});
queue.create('name', {})
.save();
queue.create('name2', {})
.save();
-
fixed_doubling
and delay_doubling
custom backoffs
- fixed_doubling - starts at 2 minutes, then 4, then 8, etc
- delay_doubling - starts at initial_delay * 2 (2 seconds if no initial delay)
const kue = require('anytv-kue')();
const queue = kue.createQueue();
queue.createJob('jobtitle', { test: 123 })
.backoff('fixed_doubling')
.save();
queue.createJob('jobtitle', { test: 123 })
.delay(1000 * 10)
.backoff('delay_doubling')
.save();
queue.createJob('jobtitle', { test: 123 })
.backoff('delay_doubling')
.save();