summaryrefslogtreecommitdiff
path: root/test/parallel/test-cluster-rr-ref.js
blob: 606ff708e94029c05bccac91c0f2f68f7a45d4b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
'use strict';

const common = require('../common');
const assert = require('assert');
const cluster = require('cluster');
const net = require('net');

if (cluster.isMaster) {
  cluster.fork().on('message', function(msg) {
    if (msg === 'done') this.kill();
  });
} else {
  const server = net.createServer(assert.fail);
  server.listen(common.PORT, function() {
    server.unref();
    server.ref();
    server.close(function() {
      process.send('done');
    });
  });
}