mirror of https://github.com/lukechilds/node.git
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.
24 lines
562 B
24 lines
562 B
9 years ago
|
'use strict';
|
||
|
const common = require('../common');
|
||
|
const http = require('http');
|
||
|
const cluster = require('cluster');
|
||
|
|
||
|
cluster.schedulingPolicy = cluster.SCHED_RR;
|
||
|
|
||
|
const server = http.createServer();
|
||
|
|
||
|
if (cluster.isMaster) {
|
||
|
server.listen(common.PORT);
|
||
|
const worker = cluster.fork();
|
||
|
worker.on('exit', common.mustCall(() => {
|
||
|
server.close();
|
||
|
}));
|
||
|
} else {
|
||
|
process.on('uncaughtException', common.mustCall((e) => {}));
|
||
|
server.listen(common.PORT);
|
||
|
server.on('error', common.mustCall((e) => {
|
||
|
cluster.worker.disconnect();
|
||
|
throw e;
|
||
|
}));
|
||
|
}
|