Skip to content

Instantly share code, notes, and snippets.

@discretepackets
Last active December 16, 2015 17:29
Show Gist options
  • Save discretepackets/5470578 to your computer and use it in GitHub Desktop.
Save discretepackets/5470578 to your computer and use it in GitHub Desktop.
var kue = require('./kue');
var jobs = kue.createQueue();
var autoscale = require('./autoscale')(jobs);
exports.create = function(type, options, callback) {
// Make 'options' parameter optional
if (typeof options === "function") {
callback = options;
options = null;
}
callback = callback || function(err) { if (err) console.log(err) };
return jobs.create(type, options).save(function(err) {
if (err) {
console.log('error adding job to kue');
return callback(err);
}
if (process.env.NODE_ENV === 'production') {
autoscale.scaleUp(function(err) {
if (err) {
console.log('error scaling up');
return callback(err);
}
callback(err);
});
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment