feat(ShardingManager): add execArgv option (#2585)

This commit is contained in:
Isabella
2018-06-23 16:09:03 -05:00
committed by GitHub
parent 58e5017159
commit bfbb723f42
2 changed files with 20 additions and 5 deletions

View File

@@ -22,6 +22,7 @@ class ShardingManager extends EventEmitter {
* @param {number|string} [options.totalShards='auto'] Number of shards to spawn, or "auto"
* @param {boolean} [options.respawn=true] Whether shards should automatically respawn upon exiting
* @param {string[]} [options.shardArgs=[]] Arguments to pass to the shard script when spawning
* @param {string[]} [options.execArgv=[]] Arguments to pass to the shard script executable when spawning
* @param {string} [options.token] Token to use for automatic shard count and passing to shards
*/
constructor(file, options = {}) {
@@ -30,6 +31,7 @@ class ShardingManager extends EventEmitter {
totalShards: 'auto',
respawn: true,
shardArgs: [],
execArgv: [],
token: null,
}, options);
@@ -70,6 +72,12 @@ class ShardingManager extends EventEmitter {
*/
this.shardArgs = options.shardArgs;
/**
* An array of arguments to pass to the executable
* @type {string[]}
*/
this.execArgv = options.execArgv;
/**
* Token to use for obtaining the automatic shard count, and passing to shards
* @type {?string}
@@ -90,7 +98,7 @@ class ShardingManager extends EventEmitter {
* @returns {Shard}
*/
createShard(id = this.shards.size) {
const shard = new Shard(this, id, this.shardArgs);
const shard = new Shard(this, id);
this.shards.set(id, shard);
/**
* Emitted upon creating a shard.