new(all): Paralel bot loading.

This commit is contained in:
rodrigorodriguez 2022-10-10 00:48:52 -03:00
parent 9c81db77c9
commit 24a3af5051

View file

@ -118,6 +118,9 @@ export class GBMinService {
*/ */
public deployer: GBDeployer; public deployer: GBDeployer;
bar1;
/** /**
* Static initialization of minimal instance. * Static initialization of minimal instance.
*/ */
@ -171,11 +174,11 @@ export class GBMinService {
// Calls mountBot event to all bots. // Calls mountBot event to all bots.
const bar1 = new cliProgress.SingleBar({ this.bar1 = new cliProgress.SingleBar({
format: '[{bar}] Loading {botId} ({value}/{total})...', barsize: 60 format: '[{bar}] Loading {botId} ({value}/{total})...', barsize: 60
}, cliProgress.Presets.rect); }, cliProgress.Presets.rect);
let i = 0; let i = 0;
bar1.start(instances.length, i, { botId: "Boot" }); this.bar1.start(instances.length, i, { botId: "Boot" });
const throttledPromiseAll = async (promises) => { const throttledPromiseAll = async (promises) => {
const MAX_IN_PROCESS = 5; const MAX_IN_PROCESS = 5;
@ -200,7 +203,7 @@ export class GBMinService {
const p = (async (instance) => { const p = (async (instance) => {
try { try {
bar1.update(i, { botId: instance.botId }); this.bar1.update(i, { botId: instance.botId });
await this['mountBot'](instance); await this['mountBot'](instance);
GBDeployer.mountGBKBAssets(`${instance.botId}.gbkb`, GBDeployer.mountGBKBAssets(`${instance.botId}.gbkb`,
@ -213,7 +216,7 @@ export class GBMinService {
await throttledPromiseAll(instances.map(instance => p(instance))); await throttledPromiseAll(instances.map(instance => p(instance)));
bar1.stop(); this.bar1.stop();
// Loads schedules. // Loads schedules.
GBLog.info(`Scheduling SET SCHEDULE .gbdialog items...`); GBLog.info(`Scheduling SET SCHEDULE .gbdialog items...`);