mirror of https://github.com/webpack/webpack.git
better disconnect
This commit is contained in:
parent
b7e776c528
commit
0460211742
|
|
@ -4,6 +4,15 @@
|
|||
*/
|
||||
var child_process = require("child_process");
|
||||
|
||||
function disconnectWorker(worker) {
|
||||
if(worker.disconnect)
|
||||
worker.disconnect();
|
||||
else if(worker.kill)
|
||||
worker.kill();
|
||||
else
|
||||
worker.process.kill();
|
||||
}
|
||||
|
||||
function Workers(moduleToFork, count) {
|
||||
this.nextId = 1;
|
||||
this.workers = [];
|
||||
|
|
@ -49,7 +58,7 @@ Workers.prototype.bindWorker = function(worker, idx) {
|
|||
callback.apply(null, result);
|
||||
}.bind(this));
|
||||
} else {
|
||||
worker.disconnect();
|
||||
disconnectWorker(worker);
|
||||
this.forkedWorkers.splice(idx, 1);
|
||||
}
|
||||
}.bind(this));
|
||||
|
|
@ -85,9 +94,7 @@ Workers.prototype.pushJob = function(worker) {
|
|||
}
|
||||
|
||||
Workers.prototype.close = function() {
|
||||
this.workers.forEach(function(worker) {
|
||||
worker.disconnect();
|
||||
});
|
||||
this.workers.forEach(disconnectWorker);
|
||||
this.workers.length = 0;
|
||||
this.workersJobs.length = 0;
|
||||
this.workersRegister.length = 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue