feat: add worker info to worker nodes
[poolifier.git] / src / worker / cluster-worker.ts
index 13735b1d697c076c547981e9d5aad8bd22633f84..16dddd2969bd50193c4fb43e762d607f08f4ca08 100644 (file)
@@ -41,10 +41,19 @@ export class ClusterWorker<
       cluster.worker as Worker,
       opts
     )
+    if (!this.isMain) {
+      this.sendToMainWorker({ workerId: this.id, started: true })
+    }
+  }
+
+  /** @inheritDoc */
+  protected get id (): number {
+    return this.getMainWorker().id
   }
 
   /** @inheritDoc */
   protected sendToMainWorker (message: MessageValue<Response>): void {
+    console.log('sending message to main worker(cluster)', message)
     this.getMainWorker().send(message)
   }