You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
366 B
17 lines
366 B
var cluster = require('cluster'); |
|
|
|
// 取决于你的实例的可用 CPU 数量 |
|
var workers = 2; |
|
|
|
if (cluster.isMaster) { |
|
for (var i = 0; i < workers; i++) { |
|
cluster.fork(); |
|
} |
|
|
|
cluster.on('exit', (worker, code, signal) => { |
|
console.log('worker %s died, restarting...', worker.process.pid); |
|
cluster.fork(); |
|
}); |
|
} else { |
|
require('./server.js') |
|
}
|
|
|