mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
cf7406927f
PR-URL: https://github.com/nodejs/node/pull/54927 Refs: https://github.com/nodejs/node/issues/54882 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
22 lines
681 B
JavaScript
22 lines
681 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const cluster = require('cluster');
|
|
const http = require('http');
|
|
|
|
if (cluster.isPrimary) {
|
|
cluster.fork();
|
|
} else {
|
|
const server = http.createServer();
|
|
server.maxConnections = 0;
|
|
server.dropMaxConnection = true;
|
|
// When dropMaxConnection is false, the main process will continue to
|
|
// distribute the request to the child process, if true, the child will
|
|
// close the connection directly and emit drop event.
|
|
server.on('drop', common.mustCall((a) => {
|
|
process.exit();
|
|
}));
|
|
server.listen(common.mustCall(() => {
|
|
http.get(`http://localhost:${server.address().port}`).on('error', console.error);
|
|
}));
|
|
}
|