2020-11-24 02:23:31 +03:00
|
|
|
const cluster = require('cluster');
|
|
|
|
|
|
|
|
async function start() {
|
2020-07-28 04:40:21 +03:00
|
|
|
const { playwrightPath, browserTypeName, launchOptions, stallOnClose } = JSON.parse(process.argv[2]);
|
2020-05-21 00:58:27 +03:00
|
|
|
if (stallOnClose) {
|
|
|
|
launchOptions.__testHookGracefullyClose = () => {
|
|
|
|
console.log(`(stalled=>true)`);
|
|
|
|
return new Promise(() => {});
|
|
|
|
};
|
|
|
|
}
|
2020-07-28 04:40:21 +03:00
|
|
|
|
2020-08-28 07:08:33 +03:00
|
|
|
const playwright = require(require('path').join(playwrightPath, 'index'));
|
2020-07-28 04:40:21 +03:00
|
|
|
|
2020-07-30 20:22:28 +03:00
|
|
|
const browserServer = await playwright[browserTypeName].launchServer(launchOptions);
|
2020-02-05 23:41:55 +03:00
|
|
|
browserServer.on('close', (exitCode, signal) => {
|
2020-05-21 00:58:27 +03:00
|
|
|
console.log(`(exitCode=>${exitCode})`);
|
|
|
|
console.log(`(signal=>${signal})`);
|
2020-01-29 00:07:53 +03:00
|
|
|
});
|
2020-05-21 00:58:27 +03:00
|
|
|
console.log(`(pid=>${browserServer.process().pid})`);
|
|
|
|
console.log(`(wsEndpoint=>${browserServer.wsEndpoint()})`);
|
2020-11-24 02:23:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (cluster.isWorker || !JSON.parse(process.argv[2]).inCluster) {
|
|
|
|
start();
|
|
|
|
} else {
|
|
|
|
cluster.fork();
|
|
|
|
cluster.on('exit', (worker, code, signal) => {
|
|
|
|
process.exit(0);
|
|
|
|
});
|
|
|
|
}
|