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

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.
6 Replies
d.js toolkit
d.js toolkitโ€ข4mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - 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
โœจ๐“œ๐“ช๐“ฒ๐“ฝ๐“ป๐“ฎ๐“–๐“”๐“”๐“šใƒ„โœจ
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
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
d.js docs
d.js docsโ€ข4mo ago
:propertysignature: ShardingManagerOptions#respawn @14.16.1 Whether shards should automatically respawn upon exiting
โœจ๐“œ๐“ช๐“ฒ๐“ฝ๐“ป๐“ฎ๐“–๐“”๐“”๐“šใƒ„โœจ
but when I kill one the shardingManager respawns it Yooo thanks As I am using multiple servers to host my bot, there are multiple shardingManager working together 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
d.js docs
d.js docsโ€ข4mo ago
:propertysignature: ShardingManagerOptions#shardList @14.16.1 List of shards to spawn or "auto"
โœจ๐“œ๐“ช๐“ฒ๐“ฝ๐“ป๐“ฎ๐“–๐“”๐“”๐“šใƒ„โœจ
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 ? 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 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 any ways thanks for your help
Want results from more Discord servers?
Add your server