X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fcluster%2Ffixed.ts;h=dbf1d470b7e7f36eb12dec0bba28c081fac60786;hb=2e2ef9c39a37f5d32bfaf75b7cfe886aac69d8cb;hp=fe920f8a48126529a31dafc2d0c9f31bb4c0e4cf;hpb=4b628b4844b461e434c5945feead43b0cc7aab01;p=poolifier.git diff --git a/src/pools/cluster/fixed.ts b/src/pools/cluster/fixed.ts index fe920f8a..dbf1d470 100644 --- a/src/pools/cluster/fixed.ts +++ b/src/pools/cluster/fixed.ts @@ -61,7 +61,7 @@ export class FixedClusterPool< /** @inheritDoc */ protected destroyWorker (worker: Worker): void { - this.sendToWorker(worker, { kill: 1 }) + this.sendToWorker(worker, { kill: true, workerId: worker.id }) worker.on('disconnect', () => { worker.kill() }) @@ -73,6 +73,22 @@ export class FixedClusterPool< worker.send(message) } + /** @inheritDoc */ + protected sendStartupMessageToWorker (worker: Worker): void { + this.sendToWorker(worker, { + ready: false, + workerId: worker.id + }) + } + + /** @inheritDoc */ + protected registerWorkerMessageListener( + worker: Worker, + listener: (message: MessageValue) => void + ): void { + worker.on('message', listener) + } + /** @inheritDoc */ protected createWorker (): Worker { return cluster.fork(this.opts.env)