#!/usr/bin/env node
/**
 * @overview Run batches
 *
 */
process.env.NODE_ENV = '{{NODE_ENV}}';

var newContext = require('../serverside/context').{{CONTEXT_LOADER_NAME}},
    b = require('../serverside/batch');

var context = newContext();

require('async').series([
    {{#each batchLoaders}}function (callback) {
        var batch = b.{{this}}(context);
        batch.run(function (err) {
            callback(err);
        });
    },
    {{/each}}
], function (err){
    if(err) {
        console.error(err.stack || err);
    }
});