Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
fix(webdriver-manager): make sure selenium standalone shuts down nicely
Browse files Browse the repository at this point in the history
This addresses selenium server shutdown in two ways
 - the node process will stay open until selenium has exited
 - if the user inputs to STDIN (e.g. press space) selenium will shut down gracefully
  • Loading branch information
juliemr committed Dec 18, 2013
1 parent d04f9a9 commit f8c606b
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions bin/webdriver-manager
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var http = require('http');
var path = require('path');
var AdmZip = require('adm-zip');
var optimist = require('optimist');
var childProcess = require('child_process');

/**
* Download the requested binaries to node_modules/protractor/selenium/
Expand Down Expand Up @@ -131,7 +132,7 @@ var spawnCommand = function(command, args) {
var winCommand = win32 ? 'cmd' : command;
var finalArgs = win32 ? ['/c'].concat(command, args) : args;

return require('child_process').spawn(winCommand, finalArgs,
return childProcess.spawn(winCommand, finalArgs,
{ stdio: 'inherit' });
};

Expand Down Expand Up @@ -207,7 +208,21 @@ switch (argv._[0]) {
args.push('-Dwebdriver.ie.driver=' +
path.join(argv.out_dir, executableName('IEDriverServer')));
}
spawnCommand('java', args);
var seleniumProcess = spawnCommand('java', args);
console.log('seleniumProcess.pid: ' + seleniumProcess.pid);
seleniumProcess.on('exit', function(code) {
console.log('Selenium Standalone has exited with code ' + code);
process.exit(code);
});
process.stdin.resume();
process.stdin.on('data', function(chunk) {
console.log('Attempting to shut down selenium nicely');
http.get('http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer');

});
process.on('SIGINT', function() {
console.log('Staying alive until the Selenium Standalone process exits');
});
break;
case 'status':
for (name in binaries) {
Expand Down

0 comments on commit f8c606b

Please sign in to comment.