forked from Galactic/galactic-bot
retry spawn with longer timeout
This commit is contained in:
parent
9446a4dc89
commit
4ab7f33767
@ -134,13 +134,35 @@ class Controller extends EventEmitter
|
||||
}
|
||||
|
||||
// const promises = [];
|
||||
const retry: Shard[] = [];
|
||||
for (let i = 0; i < shardCount; i++)
|
||||
{
|
||||
const shard = this.createShard(shardCount);
|
||||
await shard.spawn(90_000);
|
||||
try
|
||||
{
|
||||
await shard.spawn(90_000);
|
||||
}
|
||||
catch (err)
|
||||
{
|
||||
this.logger.error(err as Error);
|
||||
this.logger.info('Retrying shard', i);
|
||||
retry.push(shard);
|
||||
}
|
||||
// promises.push();
|
||||
}
|
||||
|
||||
for (const shard of retry)
|
||||
{
|
||||
try
|
||||
{
|
||||
await shard.spawn(120_000);
|
||||
}
|
||||
catch
|
||||
{
|
||||
this.logger.error(`Shard ${shard.id} failed to spawn in time`);
|
||||
}
|
||||
}
|
||||
|
||||
// await Promise.all(promises);
|
||||
|
||||
this.#logger.status(`Shards spawned, spawned ${this.#shards.size} shards. Took ${Date.now() - start} ms`);
|
||||
|
@ -132,6 +132,7 @@ class Shard extends EventEmitter
|
||||
{
|
||||
const cleanup = () =>
|
||||
{
|
||||
this.#process?.kill();
|
||||
clearTimeout(spawnTimeoutTimer); // eslint-disable-line @typescript-eslint/no-use-before-define
|
||||
this.off('ready', onReady); // eslint-disable-line @typescript-eslint/no-use-before-define
|
||||
this.off('disconnect', onDisconnect); // eslint-disable-line @typescript-eslint/no-use-before-define
|
||||
|
Loading…
Reference in New Issue
Block a user