Feat: implemented mongo store/retrieve datas for webservice and imagecreator; Feat: parallel execution of Puppets with random flow
This commit is contained in:
parent
1c8645039e
commit
ae477fc3df
11 changed files with 506 additions and 223 deletions
|
|
@ -18,8 +18,6 @@ export class Puppet {
|
|||
async execMovements(page, flow: {type: string; target: {x: number, y: number, width: number, height: number} }[]){
|
||||
|
||||
function humanize(val: number, bounduaries: {min: number, max: number}) {
|
||||
console.log(val);
|
||||
console.log(Math.random() * Math.abs(bounduaries.max));
|
||||
return val + (Math.random() * Math.abs(bounduaries.max));
|
||||
}
|
||||
|
||||
|
|
@ -46,5 +44,8 @@ export class Puppet {
|
|||
const browser = await puppeteer.launch({headless: false});
|
||||
const page = await browser.newPage();
|
||||
await this.execMovements(page, this.flow);
|
||||
await page.close();
|
||||
await browser.close();
|
||||
return 'end';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,11 +3,40 @@ import {flows} from "../../DataGeneratorPuppets/src/datas/flow";
|
|||
|
||||
function main() {
|
||||
|
||||
for(let i = 0; i < 30; i++) {
|
||||
/*for(let i = 1; i <= 5; i++) {
|
||||
let flowIndex = Math.floor(Math.random() * flows.length + 0);
|
||||
const puppet = new Puppet('', flows[flowIndex].name, 'bot_'+i, flows[flowIndex].data);
|
||||
puppet.run();
|
||||
}
|
||||
}*/
|
||||
|
||||
let puppetCounter = 0;
|
||||
let loop = true;
|
||||
let counter = 0;
|
||||
|
||||
setInterval(() =>{
|
||||
let res = [];
|
||||
if(counter < 10) {
|
||||
loop = false;
|
||||
counter++;
|
||||
let flowIndex = Math.floor(Math.random() * flows.length + 0);
|
||||
|
||||
res.push(new Puppet('', flows[flowIndex].name, 'bot_' + puppetCounter++, flows[flowIndex].data).run());
|
||||
|
||||
Promise.race(res)
|
||||
.then(val => {
|
||||
counter--;
|
||||
console.log('Adios');
|
||||
loop = true;
|
||||
});
|
||||
}
|
||||
}, 50)
|
||||
|
||||
/*
|
||||
const puppet2 = new Puppet('', flows[flowIndex].name, 'bot_'+puppetCounter++, flows[flowIndex].data).run();
|
||||
const puppet3 = new Puppet('', flows[flowIndex].name, 'bot_'+puppetCounter++, flows[flowIndex].data).run();
|
||||
const puppet4 = new Puppet('', flows[flowIndex].name, 'bot_'+puppetCounter++, flows[flowIndex].data).run();
|
||||
const puppet5 = new Puppet('', flows[flowIndex].name, 'bot_'+puppetCounter++, flows[flowIndex].data).run('infinite');*/
|
||||
|
||||
}
|
||||
|
||||
main();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue