Skip to content

Instantly share code, notes, and snippets.

@angelochen960
Last active December 17, 2015 00:19
Show Gist options
  • Save angelochen960/5520194 to your computer and use it in GitHub Desktop.
Save angelochen960/5520194 to your computer and use it in GitHub Desktop.
var kue = require('kue')
var redis = require('redis')
kue.redis.createClient = function () {
var client = redis.createClient();
client.select(2, function (status) {
console.log(status)
})
return client;
};
var jobs = kue.createQueue();
jobs.process('email', function (job, done) {
done()
});
var job = jobs.create('email', {
title: 'welcome email ', to: 'foo@bar.com', template: 'welcome-email'
})
job.save()
job.on('complete',function () {
console.log("Job complete");
}).on('failed',function () {
console.log("Job failed");
}).on('progress', function (progress) {
process.stdout.write('\r job #' + job.id + ' ' + progress + '% complete');
});
kue.app.listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment