+ return cluster.isPrimary
+ }
+
+ /** @inheritDoc */
+ protected async destroyWorkerNode (workerNodeKey: number): Promise<void> {
+ this.flushTasksQueue(workerNodeKey)
+ // FIXME: wait for tasks to be finished
+ const workerNode = this.workerNodes[workerNodeKey]
+ const worker = workerNode.worker
+ const waitWorkerExit = new Promise<void>(resolve => {
+ worker.once('exit', () => {
+ resolve()
+ })
+ })
+ worker.once('disconnect', () => {
+ worker.kill()
+ })
+ await this.sendKillMessageToWorker(workerNodeKey)
+ worker.disconnect()
+ await waitWorkerExit
+ }
+
+ /** @inheritDoc */
+ protected sendToWorker (
+ workerNodeKey: number,
+ message: MessageValue<Data>
+ ): void {
+ this.workerNodes[workerNodeKey].worker.send({
+ ...message,
+ workerId: this.workerNodes[workerNodeKey].info.id as number
+ })