Skip to content

Commit

Permalink
feat: Shard#kill method (#2454)
Browse files Browse the repository at this point in the history
* add shard#kill method

* docs consistency
  • Loading branch information
appellation authored and Lewdcario committed May 27, 2018
1 parent 14aab1b commit fc81924
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/sharding/Shard.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,23 @@ class Shard extends EventEmitter {
return this.process;
}

/**
* Kills this shard.
*/
kill() {
this.process.removeListener('exit', this._exitListener);
this.process.kill();
this._handleExit(false);
}

/**
* Kills and restarts the shard's process.
* @param {number} [delay=500] How long to wait between killing the process and restarting it (in milliseconds)
* @param {boolean} [waitForReady=true] Whether to wait until the {@link Client} has become ready before resolving
* @returns {Promise<ChildProcess>}
*/
async respawn(delay = 500, waitForReady = true) {
this.process.removeListener('exit', this._exitListener);
this.process.kill();
this._handleExit(false);
this.kill();
if (delay > 0) await Util.delayFor(delay);
return this.spawn(waitForReady);
}
Expand Down

0 comments on commit fc81924

Please sign in to comment.