Skip to content

Instantly share code, notes, and snippets.

@ermst4r
Created June 16, 2016 11:25
Show Gist options
  • Save ermst4r/8b5030c46c7853c360cdb406e0b92898 to your computer and use it in GitHub Desktop.
Save ermst4r/8b5030c46c7853c360cdb406e0b92898 to your computer and use it in GitHub Desktop.
<script>
module.exports.bootstrap = function(cb) {
_.extend(sails.hooks.http.app.locals, sails.config.http.locals);
// add the lines from here
// bootstrapping all the cronjobs in the crontab folder
var schedule = require('node-schedule');
sails.config.crontab.crons().forEach(function(item){
schedule.scheduleJob(item.interval,sails.config.crontab[item.method]);
});
// It's very important to trigger this callback method when you are finished
// with the bootstrap! (otherwise your server will never lift, since it's waiting on the bootstrap)
cb();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment