make shardmanager better (#731)

* add respawn thing for shards, and make it easier to recieve messages from shards

* run docs
This commit is contained in:
Gus Caplan
2016-09-23 12:36:14 -05:00
committed by Amish Shah
parent 4bf6ad30f3
commit fc9d049cc1
3 changed files with 15 additions and 4 deletions

View File

@@ -27,6 +27,14 @@ class Shard {
* @type {ChildProcess}
*/
this.process = childProcess.fork(path.resolve(this.manager.file), [id, this.manager.shards.size]);
this.process.once('exit', () => {
if (this.manager.respawn) this.manager.createShard(this.id);
});
this.process.on('message', message => {
this.manager.emit('message', this, message);
});
}
/**