This commit is contained in:
William Mantly 2016-04-22 12:21:03 -04:00
parent 147d7ab41f
commit 57cfc24e92

View File

@ -15,7 +15,7 @@ var ip2name = {};
var lxcTimeout = function(ip, time){ var lxcTimeout = function(ip, time){
var name = ip2name[ip]; var name = ip2name[ip];
console.log(name) console.log(name)
time = time || 100000; time = time || 900000; // 15 minutes
var keys = Object.keys(timeoutEvents) var keys = Object.keys(timeoutEvents)
if(keys.indexOf(name) !== -1){ if(keys.indexOf(name) !== -1){
clearTimeout(timeoutEvents[name]) clearTimeout(timeoutEvents[name])
@ -28,7 +28,7 @@ var lxcTimeout = function(ip, time){
var runner = function(req, res, ip){ var runner = function(req, res, ip){
lxcTimeout(ip, 30000); lxcTimeout(ip);
return request.post({url:'http://'+ip, form: req.body}, function(error, response, body){ return request.post({url:'http://'+ip, form: req.body}, function(error, response, body){
body = JSON.parse(body); body = JSON.parse(body);
body['ip'] = ip.replace('10.0.', ''); body['ip'] = ip.replace('10.0.', '');
@ -131,8 +131,8 @@ router.post('/run/:ip?', function doRun(req, res, next){
if(found){ if(found){
return runner(req, res, ip) return runner(req, res, ip)
}else{ }else{
var name = 'u1-'+(Math.random()*100).toString().replace('.',''); var name = 'crunner-'+(Math.random()*100).toString().replace('.','');
return lxc.startEphemeral(name, 'u1', function(data){ return lxc.startEphemeral(name, 'crunner', function(data){
ip2name[data.ip] = name; ip2name[data.ip] = name;
return runner(req, res, data.ip); return runner(req, res, data.ip);
}); });