diff --git a/app/modules/prover/lib/powCluster.ts b/app/modules/prover/lib/powCluster.ts index cd9c7c23981bf2d681536a7cec44ed09dce0dfd8..552a2e779fb926787beb831bf999603023079ee9 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)