JacksonTian / diveintonode_examples

《深入浅出Node.js》的相关代码
426 stars 193 forks source link

朴灵老师,多进程中,如果创建子进程之后server.close(),就不能再次fork进程了 #13

Open clancytom opened 6 years ago

clancytom commented 6 years ago
for (var i = 0; i < cpus.length; i++) {
  createWorker();
}
server.close();
var server = http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('handled by child, pid is ' + process.pid + '\n');
  throw new Error('throw exception');
});
TypeError: Cannot read property '_simultaneousAccepts' of null
    at Object._setSimultaneousAccepts (net.js:1706:16)
    at ChildProcess.target._send (internal/child_process.js:657:13)
    at ChildProcess.target.send (internal/child_process.js:586:19)
    at Master.forkWorker (G:\code\config-app-soa-master\config-app\ds-uibuilder\dist\src\server\cluster\master.js:60:16)
    at ChildProcess.worker.on (G:\code\config-app-soa-master\config-app\ds-uibuilder\dist\src\server\cluster\master.js:71:18)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
clancytom commented 6 years ago

子进程挂掉之后,父进程的监听已经关闭了,此时如何才能重新fork进程了

JacksonTian commented 6 years ago

什么版本。

clancytom commented 6 years ago
G:\code\config-app-soa-master\config-app\ds-uibuilder>node -v
v8.9.2