From dc27bc3da18e3c093efe41836fb440726e2a4dee Mon Sep 17 00:00:00 2001 From: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> Date: Wed, 14 Apr 2021 18:06:41 +0000 Subject: [PATCH] fix: delay each shard by 5 seconds --- src/ws/spawn_shards.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ws/spawn_shards.ts b/src/ws/spawn_shards.ts index d82c15d88..00ebf2305 100644 --- a/src/ws/spawn_shards.ts +++ b/src/ws/spawn_shards.ts @@ -1,4 +1,5 @@ import { Collection } from "../util/collection.ts"; +import { delay } from "../util/utils.ts"; import { ws } from "./ws.ts"; /** Begin spawning shards. */ @@ -46,6 +47,7 @@ export function spawnShards(firstShardId = 0) { } } + console.log("BUCKETS", buckets); // SPREAD THIS OUT TO DIFFERENT CLUSTERS TO BEGIN STARTING UP buckets.forEach(async (bucket, bucketId) => { ws.log( @@ -61,6 +63,12 @@ export function spawnShards(firstShardId = 0) { while (shardId !== undefined) { ws.log("DEBUG", "Running while loop in getMembers function."); + if (!ws.createNextShard) { + await delay(100); + continue; + } + + ws.createNextShard = false; await ws.tellClusterToIdentify(clusterId as number, shardId, bucketId); shardId = queue.shift(); }