Controller
This commit is contained in:
parent
f2f62ec145
commit
b0828f049b
@ -49,15 +49,21 @@ class Controller extends EventEmitter {
|
||||
async init () {
|
||||
|
||||
this.logger.info(`Initialising Controller`);
|
||||
const { shardCount = 1, shardOptions = {}, serverOptions = {} } = this._options;
|
||||
const { shardCount = 1, shardOptions = {}, serverOptions = {}, logger = {}, discord = {}, databases = {} } = this._options;
|
||||
this.logger.info(`Spawning ${shardCount} shards`);
|
||||
|
||||
const promises = [];
|
||||
for (let i = 0; i < shardCount; i++) {
|
||||
const shard = new Shard(this, i, { serverOptions, ...shardOptions, env: this._options.env, path: this.filePath });
|
||||
const shard = new Shard(this, i, { serverOptions: { ...serverOptions, logger, discord, databases }, ...shardOptions, env: this._options.env, path: this.filePath });
|
||||
this.logger.attach(shard);
|
||||
this._setListeners(shard);
|
||||
this.shards.set(i, shard);
|
||||
promises.push(shard.spawn());
|
||||
|
||||
// setTimeout(() => {
|
||||
// shard.kill();
|
||||
// }, 10_000);
|
||||
|
||||
}
|
||||
|
||||
await Promise.all(promises);
|
||||
@ -66,6 +72,7 @@ class Controller extends EventEmitter {
|
||||
}
|
||||
|
||||
_handleMessage (shard, msg) {
|
||||
if (msg._logger) return;
|
||||
this.logger.debug(`Message from ${shard.id}: ${inspect(msg)}`);
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ class Shard extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
this.emit('message', this, message);
|
||||
this.emit('message', message);
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user