diff --git a/app/app.js b/app/app.js index 73a9611c..0c0ca805 100644 --- a/app/app.js +++ b/app/app.js @@ -28,7 +28,7 @@ var CacheStatusController = require('./controllers/cache_status_controller'); var HealthCheckController = require('./controllers/health_check_controller'); var VersionController = require('./controllers/version_controller'); -var Batch = require('../batch'); +var batch = require('../batch'); process.env.PGAPPNAME = process.env.PGAPPNAME || 'cartodb_sqlapi'; @@ -180,9 +180,10 @@ function App() { var versionController = new VersionController(); versionController.route(app); - if (global.settings.environment !== 'test') { - var batch = new Batch(metadataBackend); - batch.start(); + var isBatchProcess = process.argv.indexOf('--no-batch') === -1; + + if (global.settings.environment !== 'test' && isBatchProcess) { + batch(metadataBackend).start(); } return app; diff --git a/test/acceptance/batch.test.js b/test/acceptance/batch.test.js index 2e480201..698aecc7 100644 --- a/test/acceptance/batch.test.js +++ b/test/acceptance/batch.test.js @@ -1,7 +1,6 @@ var _ = require('underscore'); var queue = require('queue-async'); -var Batch = require('../../batch'); -// var Batch = require('../../batch/batch'); +var batchFactory = require('../../batch'); var JobPublisher = require('../../batch/job_publisher'); var JobQueue = require('../../batch/job_queue'); var UserIndexer = require('../../batch/user_indexer'); @@ -22,7 +21,7 @@ describe('batch module', function() { var userIndexer = new UserIndexer(metadataBackend); var jobBackend = new JobBackend(metadataBackend, jobQueue, jobPublisher, userIndexer); - var batch = new Batch(metadataBackend); + var batch = batchFactory(metadataBackend); before(function () { batch.start();