mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 19:13:31 +01:00
Add getRecommendedShards and automatic shard count in ShardingManager (#796)
* draft stuff fix docstring for Client#token Reorganise resolver make env better for shards, clean up docs Fix Gus' log messages 7 meh just gateway/bot not v7 :( final changes, ready for mergin! build docs make default totalShards 'auto', fix docs for totalShards type clean up docs more run docs * make consistancy real * Update and rename getRecommendedShards.js to GetRecommendedShards.js * Update GetRecommendedShards.js * Update index.js * Update RESTMethods.js * Update Shard.js * Update GetRecommendedShards.js * Update ShardingManager.js * run docs
This commit is contained in:
committed by
Schuyler Cebulskie
parent
492f706035
commit
853a3dfa04
@@ -10,7 +10,7 @@ class Shard {
|
||||
/**
|
||||
* @param {ShardingManager} manager The sharding manager
|
||||
* @param {number} id The ID of this shard
|
||||
* @param {array} [spawnArgs=] Optional command line arguments to pass to the shard
|
||||
* @param {array} [spawnArgs=[]] Command line arguments to pass to the shard
|
||||
*/
|
||||
constructor(manager, id, spawnArgs = []) {
|
||||
/**
|
||||
@@ -25,15 +25,22 @@ class Shard {
|
||||
*/
|
||||
this.id = id;
|
||||
|
||||
/**
|
||||
* The environment variables for the shard
|
||||
* @type {Object}
|
||||
*/
|
||||
this.env = {
|
||||
SHARD_ID: this.id,
|
||||
SHARD_COUNT: this.manager.totalShards,
|
||||
};
|
||||
if (this.manager.token) this.env.CLIENT_TOKEN = this.manager.token;
|
||||
|
||||
/**
|
||||
* Process of the shard
|
||||
* @type {ChildProcess}
|
||||
*/
|
||||
this.process = childProcess.fork(path.resolve(this.manager.file), spawnArgs, {
|
||||
env: {
|
||||
SHARD_ID: this.id,
|
||||
SHARD_COUNT: this.manager.totalShards,
|
||||
},
|
||||
env: this.env,
|
||||
});
|
||||
this.process.on('message', this._handleMessage.bind(this));
|
||||
this.process.once('exit', () => {
|
||||
|
||||
Reference in New Issue
Block a user