diff --git a/packages/core.gbapp/services/GBMinService.ts b/packages/core.gbapp/services/GBMinService.ts index 7b120412..af5c855a 100644 --- a/packages/core.gbapp/services/GBMinService.ts +++ b/packages/core.gbapp/services/GBMinService.ts @@ -170,25 +170,28 @@ export class GBMinService { // Calls mountBot event to all bots. - + const bar1 = new cliProgress.SingleBar({ - format: '[{bar}] Loading {botId} ({value}/{total})...', barsize:60 + format: '[{bar}] Loading {botId} ({value}/{total})...', barsize: 60 }, cliProgress.Presets.rect); let i = 0; - bar1.start(instances.length, i, {botId: "Boot"}); - - await CollectionUtil.asyncForEach(instances, async instance => { + bar1.start(instances.length, i, { botId: "Boot" }); + + const p = (async (instance) => { try { - bar1.update(i, {botId: instance.botId}); - - await this.mountBot(instance); + bar1.update(i, { botId: instance.botId }); + + await this['mountBot'](instance); GBDeployer.mountGBKBAssets(`${instance.botId}.gbkb`, - instance.botId, `${instance.botId}.gbkb`); + instance.botId, `${instance.botId}.gbkb`); i++; } catch (error) { GBLog.error(`Error mounting bot ${instance.botId}: ${error.message}\n${error.stack}`); } - }); + }).bind(this); + + Promise.all(instances.map(instance => p(instance))); + bar1.stop(); // Loads schedules. diff --git a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts index 67c1452b..a0fceefe 100644 --- a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts +++ b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts @@ -202,7 +202,7 @@ export class WhatsappDirectLine extends GBService { client.on('authenticated', async () => { this.browserWSEndpoint = client.pupBrowser.wsEndpoint(); - GBLog.verbose(`\nGBWhatsApp: QR Code authenticated for ${this.botId}.`); + GBLog.verbose(`GBWhatsApp: QR Code authenticated for ${this.botId}.`); }); client.on('ready', async () => { @@ -212,7 +212,7 @@ export class WhatsappDirectLine extends GBService { await (createClient.bind(this))(null); }).bind(this)); - GBLog.verbose(`\nGBWhatsApp: Emptying chat list for ${this.botId}...`); + GBLog.verbose(`GBWhatsApp: Emptying chat list for ${this.botId}...`); // Keeps the chat list cleaned.