diff --git a/routes/api.js b/routes/api.js index 8e2a51a..3b785f1 100644 --- a/routes/api.js +++ b/routes/api.js @@ -9,6 +9,11 @@ var doapi = require('../doapi')(); var workers = require('./worker_collection.js'); +(function(){ + console.log('========STARTING===========') + setInterval(workers.checkBalance, 15000); + workers.destroyByTag(); +})() var attemptRun = function(req, res, runner, count){ count = count || 0; @@ -62,11 +67,6 @@ var attemptRun = function(req, res, runner, count){ }); }; -console.log('========STARTING===========') -// TODO: Make this a function -setInterval(workers.checkBalance, 15000); -workers.destroyByTag(); - // Why is this a GET? router.get('/stop/:name', function(req, res, next){ return lxc.stop(req.params.name, function(data){