summaryrefslogtreecommitdiff
path: root/test/parallel/test-cluster-setup-master-emit.js
blob: aad1cea75eda972d2fc8a78f36f55eb8aec9531d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
'use strict';
const common = require('../common');
var assert = require('assert');
var cluster = require('cluster');

assert(cluster.isMaster);

function emitAndCatch(next) {
  cluster.once('setup', common.mustCall(function(settings) {
    assert.strictEqual(settings.exec, 'new-exec');
    setImmediate(next);
  }));
  cluster.setupMaster({ exec: 'new-exec' });
}

function emitAndCatch2(next) {
  cluster.once('setup', common.mustCall(function(settings) {
    assert('exec' in settings);
    setImmediate(next);
  }));
  cluster.setupMaster();
}

emitAndCatch(common.mustCall(function() {
  emitAndCatch2(common.mustCall(function() {}));
}));