}
}
- private get starting (): boolean {
- return this.workerNodes.some(workerNode => !workerNode.info.started)
- }
-
- private get started (): boolean {
- return this.workerNodes.some(workerNode => workerNode.info.started)
- }
-
/** @inheritDoc */
public get info (): PoolInfo {
return {
if (this.emitter != null) {
this.emitter.emit(PoolEvents.error, error)
}
- if (this.opts.restartWorkerOnError === true && !this.starting) {
+ if (this.opts.restartWorkerOnError === true) {
this.createAndSetupWorker()
}
})
cluster.worker as Worker,
opts
)
- if (!this.isMain) {
- this.sendToMainWorker({ workerId: this.id, started: true })
- }
}
/** @inheritDoc */
/** @inheritDoc */
protected sendToMainWorker (message: MessageValue<Response>): void {
- console.log('sending message to main worker(cluster)', message)
this.getMainWorker().send(message)
}
parentPort as MessagePort,
opts
)
- if (!this.isMain) {
- this.sendToMainWorker({ workerId: this.id, started: true })
- }
}
protected get id (): number {
/** @inheritDoc */
protected sendToMainWorker (message: MessageValue<Response>): void {
- console.log('sending message to main worker(thread)', message)
this.getMainWorker().postMessage(message)
}
}
maxQueuedTasks: 0,
failedTasks: 0
})
- for (const workerNode of pool.workerNodes) {
- console.log('thread:workerNode.info', workerNode.info)
- }
await pool.destroy()
pool = new DynamicClusterPool(
numberOfWorkers,
maxQueuedTasks: 0,
failedTasks: 0
})
- for (const workerNode of pool.workerNodes) {
- console.log('cluster:workerNode.info', workerNode.info)
- }
await pool.destroy()
})