simpler
This commit is contained in:
parent
b45f45153f
commit
14a628a8ff
@ -215,9 +215,10 @@ var workers = (function(){
|
||||
workers.checkForZombies();
|
||||
|
||||
// if there are workers being created, stop scale up and down check
|
||||
if(workers.currentCreating) return ;
|
||||
if(workers.currentCreating+workers.length < workers.min) 'do nothing';
|
||||
else if(workers.currentCreating)
|
||||
return ;
|
||||
|
||||
// scale up and down check
|
||||
|
||||
// hold amount of workers with no used runners
|
||||
var lastMinAval = 0;
|
||||
@ -234,13 +235,23 @@ var workers = (function(){
|
||||
|
||||
if(lastMinAval > workers.settings.minAvail){
|
||||
// Remove workers if there are more then the settings states
|
||||
console.log('Last 3 runners not used, killing last runner', workers.length);
|
||||
console.log(
|
||||
'Last 3 runners not used, killing last runner',
|
||||
'lastMinAval:', lastMinAval,
|
||||
'minAvail:', workers.settings.minAvail,
|
||||
'workers:', workers.length
|
||||
);
|
||||
|
||||
return workers.destroy();
|
||||
|
||||
} else if(lastMinAval < workers.settings.minAvail){
|
||||
// creates workers if the settings file demands it
|
||||
console.log('last 3 workers have no free runners, starting droplet');
|
||||
console.log(
|
||||
'last 3 workers have no free runners, starting droplet',
|
||||
'lastMinAval:', lastMinAval,
|
||||
'minAvail:', workers.settings.minAvail,
|
||||
'workers:', workers.length
|
||||
);
|
||||
|
||||
return workers.create();
|
||||
}
|
||||
|
14
testAPI.js
14
testAPI.js
@ -1,16 +1,18 @@
|
||||
const request = require('request');
|
||||
|
||||
var till = 15;
|
||||
var till = 5;
|
||||
var completed = 0;
|
||||
var errors = 0;
|
||||
|
||||
for(let i=0; i<till; i++){
|
||||
console.log('calling', i);
|
||||
let httpOptions = {
|
||||
url: 'http://codeland.bytedev.co:2000/api/run',
|
||||
url: 'http://codeland.bytedev.co:2000/api/run?once=true',
|
||||
form: {
|
||||
code: `python3 -c "print(1)"`,
|
||||
once: true,
|
||||
code: `python3 -c "
|
||||
from time import sleep
|
||||
sleep(10)
|
||||
"`,
|
||||
}
|
||||
};
|
||||
request.post(httpOptions, function(error, response, body){
|
||||
@ -20,8 +22,8 @@ for(let i=0; i<till; i++){
|
||||
}
|
||||
|
||||
body = JSON.parse(body);
|
||||
|
||||
console.log(i, body);
|
||||
let res = (Buffer.from(body.res, 'base64').toString('ascii'));
|
||||
console.log(i, res);
|
||||
if(completed===till){
|
||||
console.log(errors);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user