Created
March 8, 2018 20:45
-
-
Save MiguelCedric/1b82fb7ad95de3a3c9170d8d4dd7e51e to your computer and use it in GitHub Desktop.
Agenda Configuration
This file contains hidden or 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
const Agenda = require('agenda'); | |
const mongoConnectionString = 'mongodb://localhost:27017/yourdatabase'; | |
// or override the default collection name: | |
let agenda = new Agenda({db: {address: mongoConnectionString, collection: 'jobs'}}); | |
let jobTypes = process.env.JOB_TYPES ? process.env.JOB_TYPES.split(',') : []; | |
jobTypes.forEach(function(type) { | |
require('./jobs/' + type)(agenda); | |
}); | |
if(jobTypes.length) { | |
agenda.on('ready', function() { | |
agenda.start(); | |
}); | |
} | |
function graceful() { | |
agenda.stop(function() { | |
process.exit(0); | |
}); | |
} | |
process.on('SIGTERM', graceful); | |
process.on('SIGINT' , graceful); | |
module.exports = agenda; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment