From d549083c35fbfadc38b04597278c2ebfef684b2b Mon Sep 17 00:00:00 2001
From: librelois <elois@ifee.fr>
Date: Tue, 19 Dec 2017 16:37:53 +0100
Subject: [PATCH] [fix] #1234 kill and recreate pow workers for each block

---
 app/modules/prover/lib/powCluster.ts | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/app/modules/prover/lib/powCluster.ts b/app/modules/prover/lib/powCluster.ts
index cd9c7c239..552a2e779 100644
--- a/app/modules/prover/lib/powCluster.ts
+++ b/app/modules/prover/lib/powCluster.ts
@@ -145,11 +145,7 @@ export class Master {
 
   cancelWork() {
     this.logger.info(`Cancelling the work on PoW cluster of %s slaves`, this.slaves.length)
-    this.slaves.forEach(s => {
-      s.worker.send({
-        command: 'cancel'
-      })
-    })
+    this.shutDownWorkers()
 
     // Eventually force the end of current promise
     if (this.currentPromise && !this.currentPromise.isFulfilled()) {
@@ -175,6 +171,14 @@ export class Master {
       await Promise.all(this.slaves.map(async (s:any) => {
         s.worker.kill()
       }))
+
+      // Eventually hard kill persistent workers
+      this.slaves.forEach(s => {
+        if (!s.worker.isDead()) {
+          s.worker.kill('SIGKILL')
+        }
+      })
+
       cluster.removeListener('exit', this.exitHandler)
       cluster.removeListener('online', this.onlineHandler)
       cluster.removeListener('message', this.messageHandler)
-- 
GitLab