UNPKG

943 BJavaScriptView Raw
1var spawn = require('child_process').spawn,
2 self = require('../selenium-server'),
3 fs = require('fs'),
4 wd = __dirname + '/../..',
5 args = process.argv.slice(2),
6 selenium
7 = spawn(
8 'java',
9 ['-jar', self.path].concat(args)
10 ),
11 ok = false,
12 out = fs.createWriteStream(wd + '/logs/selenium.out', {flags: 'a'}),
13 err = fs.createWriteStream(wd + '/logs/selenium.err', {flags: 'a'});
14
15selenium.stderr.on('data', function(data) {
16 if (/^execvp\(\)/.test(data)) {
17 console.log('Failed to start selenium. Please ensure that java '+
18 'is in your system path');
19 }
20 else if (!ok) {
21 ok = true;
22 console.log("Selenium is started.");
23 console.log("All output can be found at: " + wd + '/logs');
24 }
25});
26
27selenium.stdout.pipe(out);
28selenium.stderr.pipe(err);
29
30process.on("SIGTERM", function () {
31 selenium.kill("SIGTERM");
32 process.exit(1);
33});