X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fcluster%2Ffixed.ts;h=9470cccd857321388d70e0bf7f09de1a20505cfe;hb=e4c07d066abc51e978a18f44a973a548f24fb7ad;hp=c7c95c4b3dad537b39dfd44d37481178035fcb4c;hpb=0676e5d32c8f8ee5c5b7f5998f4973b0a276460f;p=poolifier.git diff --git a/src/pools/cluster/fixed.ts b/src/pools/cluster/fixed.ts index c7c95c4b..9470cccd 100644 --- a/src/pools/cluster/fixed.ts +++ b/src/pools/cluster/fixed.ts @@ -63,8 +63,9 @@ export class FixedClusterPool< protected async destroyWorkerNode (workerNodeKey: number): Promise { this.flushTasksQueue(workerNodeKey) // FIXME: wait for tasks to be finished - const worker = this.workerNodes[workerNodeKey].worker - const waitWorkerExit = new Promise((resolve) => { + const workerNode = this.workerNodes[workerNodeKey] + const worker = workerNode.worker + const waitWorkerExit = new Promise(resolve => { worker.on('exit', () => { resolve() }) @@ -72,7 +73,7 @@ export class FixedClusterPool< worker.on('disconnect', () => { worker.kill() }) - await this.sendKillMessageToWorker(workerNodeKey, worker.id) + await this.sendKillMessageToWorker(workerNodeKey) worker.disconnect() await waitWorkerExit } @@ -82,14 +83,16 @@ export class FixedClusterPool< workerNodeKey: number, message: MessageValue ): void { - this.workerNodes[workerNodeKey].worker.send(message) + this.workerNodes[workerNodeKey].worker.send({ + ...message, + workerId: this.workerNodes[workerNodeKey].info.id as number + }) } /** @inheritDoc */ protected sendStartupMessageToWorker (workerNodeKey: number): void { this.sendToWorker(workerNodeKey, { - ready: false, - workerId: this.workerNodes[workerNodeKey].worker.id + ready: false }) }