<commit_before>var createJob = require('./createJob');

module.exports = function (sails) {
  return {
    jobs: {},

    defaults: {cron: {}},

    initialize: function (cb) {
      var config = sails.config.cron;
      var tasks = Object.keys(config);
      tasks.forEach(function (name) {
        this.jobs[name] = createJob({
          cronTime: config[name].schedule,
          onTick: config[name].onTick,
          onComplete: config[name].onComplete,
          start: typeof config[name].start === 'boolean' ? config[name].start : true,
          timezone: config[name].timezone,
          context: config[name].context
        });
      }.bind(this));

      cb();
    }
  };
};
<commit_msg>Start cron tasks after Sails is fully loaded<commit_after>var createJob = require('./createJob');

module.exports = function (sails) {
  return {
    jobs: {},

    defaults: {cron: {}},

    initialize: function (cb) {
      var config = sails.config.cron;
      var tasks = Object.keys(config);
      sails.on('ready', function () {
        tasks.forEach(function (name) {
          this.jobs[name] = createJob({
            cronTime: config[name].schedule,
            onTick: config[name].onTick,
            onComplete: config[name].onComplete,
            start: typeof config[name].start === 'boolean' ? config[name].start : true,
            timezone: config[name].timezone,
            context: config[name].context
          });
        }.bind(this));
      }.bind(this));

      cb();
    }
  };
};

{'fraction_non_alphanumeric': 0.152317880794702, 'fraction_numerical': 0.0, 'mean_word_length': 2.3063457330415753, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5233161', 'n_tokens_mistral': 454, 'n_tokens_neox': 439, 'n_words': 92}