new(all): Paralel bot loading.
This commit is contained in:
parent
73f20825e7
commit
16801fcb6c
2 changed files with 15 additions and 12 deletions
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue