forked from Automattic/kue
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
53 changed files
with
3,574 additions
and
1,186 deletions.
There are no files selected for viewing
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
var kue = require('../'); | ||
|
||
// create our job queue | ||
|
@@ -10,36 +9,32 @@ var jobs = kue.createQueue(); | |
var minute = 60000; | ||
|
||
var email = jobs.create('email', { | ||
title: 'Account renewal required' | ||
, to: '[email protected]' | ||
, template: 'renewal-email' | ||
title: 'Account renewal required', to: '[email protected]', template: 'renewal-email' | ||
}).delay(minute) | ||
.priority('high') | ||
.save(); | ||
.priority('high') | ||
.save(); | ||
|
||
|
||
email.on('promotion', function(){ | ||
console.log('renewal job promoted'); | ||
email.on('promotion', function () { | ||
console.log('renewal job promoted'); | ||
}); | ||
|
||
email.on('complete', function(){ | ||
console.log('renewal job completed'); | ||
email.on('complete', function () { | ||
console.log('renewal job completed'); | ||
}); | ||
|
||
jobs.create('email', { | ||
title: 'Account expired' | ||
, to: '[email protected]' | ||
, template: 'expired-email' | ||
title: 'Account expired', to: '[email protected]', template: 'expired-email' | ||
}).delay(minute * 10) | ||
.priority('high') | ||
.save(); | ||
.priority('high') | ||
.save(); | ||
|
||
jobs.promote(); | ||
|
||
jobs.process('email', 10, function(job, done){ | ||
setTimeout(function(){ | ||
done(); | ||
}, Math.random() * 5000); | ||
jobs.process('email', 10, function (job, done) { | ||
setTimeout(function () { | ||
done(); | ||
}, Math.random() * 5000); | ||
}); | ||
|
||
// start the UI | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,34 @@ | ||
|
||
var kue = require('../') | ||
|
||
var jobs = kue.createQueue() | ||
|
||
|
||
function generateJobs() { | ||
for (var i=0; i<12; i++) { | ||
console.log('Creating Job #' + i); | ||
jobs.create('long render', { | ||
title: 'rendering frame #' + i | ||
}).save(); | ||
} | ||
for (var i = 0; i < 12; i++) { | ||
console.log('Creating Job #' + i); | ||
jobs.create('long render', { | ||
title: 'rendering frame #' + i | ||
}).save(); | ||
} | ||
} | ||
|
||
|
||
jobs.process('long render', 4, function(job, done) { | ||
console.log('Starting ' + job.data.title); | ||
setTimeout(function() { | ||
console.log('Finished ' + job.data.title); | ||
done(); | ||
}, 3000); | ||
jobs.process('long render', 4, function (job, done) { | ||
console.log('Starting ' + job.data.title); | ||
setTimeout(function () { | ||
console.log('Finished ' + job.data.title); | ||
done(); | ||
}, 3000); | ||
}) | ||
|
||
|
||
generateJobs(); | ||
|
||
setTimeout(function() { | ||
console.log('[ Shutting down when all jobs finish... ]'); | ||
jobs.shutdown(function(err) { | ||
console.log('[ All jobs finished. Kue is shut down. ]'); | ||
process.exit(0); | ||
}) | ||
setTimeout(function () { | ||
console.log('[ Shutting down when all jobs finish... ]'); | ||
jobs.shutdown(function (err) { | ||
console.log('[ All jobs finished. Kue is shut down. ]'); | ||
process.exit(0); | ||
}) | ||
}, 4200) | ||
|
Oops, something went wrong.