#How to kill a shard and prevent its auto respawn functionnality?

31 messages · Page 1 of 1 (latest)

storm glen
#

Hello,

I m using the ShardingManager and I want to know how to prevent the shards you kill with shard.kill() to automatically respawn after it? Without restarting the ShardingManager.

junior hearthBOT
#
  • What's your exact discord.js npm list discord.js and node node -v version?
  • Not a discord.js issue? Check out #1081585952654360687.
  • Consider reading #how-to-get-help to improve your question!
  • Explain what exactly your issue is.
  • Post the full error stack trace, not just the top part!
  • Show your code!
  • Issue solved? Press the button!
  • Marked as resolved by OP
crisp mica
#

What’s the use case here?

storm glen
#

The goal is that when my API asks the manager to stop a shard it stops it

#

Actually I have that as the code :

let shard = manager.shards.get(shardId);
                    if (shard) {
                        await promisifiedLog(`Stopping shard ${shardId}...`);
                        shard.process.kill(); // Arrête le processus du shard
                        shardsActive = shardsActive.filter(i => i !== shardId); // Retire du tableau des shards actifs
mellow lintelBOT
storm glen
#

but when I kill one the shardingManager respawns it

#

Yooo

#

thanks

crisp mica
storm glen
#

but

#

discord.js is not made for this

#

it's made for only one execution of a shardingManager

#

and so it's possible that when restarting the shardingManager simultaneously that some of them takes the same shard and so a shard could be launched 2 times

crisp mica
mellow lintelBOT
storm glen
#

Yep but

#

the problem is that

#

if one shardingManager shutdown

#

the shards are stopped and these shards are abandonned

#

so the servers on these shards cannot access the bot anymore ?

crisp mica
#

And how is that related to two sharding managers serving the same shards on restart?

storm glen
#

Well, you need to have an intermediate between the shardingManagers right ?

#

So that if one's down we can restart another

#

Maybe I m doing this wrong, I don't know

crisp mica
#

If one’s down (and unable to restart for whatever reason; that in itself would need an investigation how that could happen in the first place) you should start an instance somewhere else that serves the same shards, yes. But then you‘d only need to kill the whole ShardingManager process and all its shards. Not a single shard

storm glen
#

You're right for that

#

But I think that the difference and the thing I didn't told you is that all shardingManager have a number of max shards they can handle but I don't want them to use this max number by default, only when it's necessary. So my API tells to the shardingManagers that are avaialable to receive a shard to launch a shard. But, if we reload the API, it doesn't know which ones are started so it gets all the shards already launched and at this moment others shardingManager could take shards that are already launched somewhere else and so if a manager tries to start a shard that is already launched the API tells him to stop

#

well

#

by writing this I m thinking that maybe there's something to do to prevent launching shards before getting already launched shards but not sure how to do that