2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2016-05-14 23:02:18 -07:00
|
|
|
const common = require('../common');
|
|
|
|
const assert = require('assert');
|
|
|
|
const spawn = require('child_process').spawn;
|
2013-05-02 08:34:22 +02:00
|
|
|
|
2016-05-25 23:06:07 -07:00
|
|
|
const PORT_MIN = common.PORT + 1; // The fixture uses common.PORT.
|
2015-12-16 15:20:46 +01:00
|
|
|
const PORT_MAX = PORT_MIN + 2;
|
2013-05-02 08:34:22 +02:00
|
|
|
|
2016-05-14 23:02:18 -07:00
|
|
|
const args = [
|
2015-12-16 15:20:46 +01:00
|
|
|
'--debug=' + PORT_MIN,
|
2013-05-02 08:34:22 +02:00
|
|
|
common.fixturesDir + '/clustered-server/app.js'
|
|
|
|
];
|
|
|
|
|
2015-12-16 15:20:46 +01:00
|
|
|
const child = spawn(process.execPath, args);
|
|
|
|
child.stderr.setEncoding('utf8');
|
2013-05-02 08:34:22 +02:00
|
|
|
|
2016-05-14 23:02:18 -07:00
|
|
|
const checkMessages = common.mustCall(() => {
|
|
|
|
for (let port = PORT_MIN; port <= PORT_MAX; port += 1) {
|
2016-08-15 11:23:34 +02:00
|
|
|
assert(stderr.includes(`Debugger listening on 127.0.0.1:${port}`));
|
2016-05-14 23:02:18 -07:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-12-16 15:20:46 +01:00
|
|
|
let stderr = '';
|
2016-01-28 10:21:57 -05:00
|
|
|
child.stderr.on('data', (data) => {
|
2016-05-14 23:02:18 -07:00
|
|
|
process.stderr.write(`[DATA] ${data}`);
|
2015-12-16 15:20:46 +01:00
|
|
|
stderr += data;
|
2016-05-14 23:02:18 -07:00
|
|
|
if (child.killed !== true && stderr.includes('all workers are running')) {
|
2015-12-16 15:20:46 +01:00
|
|
|
child.kill();
|
2016-05-14 23:02:18 -07:00
|
|
|
checkMessages();
|
|
|
|
}
|
2013-09-06 02:44:16 +02:00
|
|
|
});
|