When the SELENIUM_SERVER_PORT environment variable is set, it will be used and a RC server will not be started

This commit is contained in:
Wilhelm Bierbaum wilhelm@twitter.com 2010-03-08 11:05:58 -08:00
parent 273f429754
commit 199517abaa
1 changed files with 23 additions and 12 deletions

View File

@ -27,29 +27,40 @@ module Jasmine
stop_servers
end
def start_servers
def start_jasmine_server
@jasmine_server_port = Jasmine::find_unused_port
@selenium_server_port = Jasmine::find_unused_port
server = Jasmine::Server.new(@jasmine_server_port, self)
@selenium_pid = fork do
Process.setpgrp
exec "java -jar #{@selenium_jar_path} -port #{@selenium_server_port} > /dev/null 2>&1"
end
puts "selenium started. pid is #{@selenium_pid}"
@jasmine_server_pid = fork do
Process.setpgrp
server.start
exit! 0
end
puts "jasmine server started. pid is #{@jasmine_server_pid}"
Jasmine::wait_for_listener(@selenium_server_port, "selenium server")
Jasmine::wait_for_listener(@jasmine_server_port, "jasmine server")
end
def external_selenium_server_port
ENV['SELENIUM_SERVER_PORT'] && ENV['SELENIUM_SERVER_PORT'].to_i > 0 ? ENV['SELENIUM_SERVER_PORT'].to_i : nil
end
def start_selenium_server
@selenium_server_port = external_selenium_server_port
if @selenium_server_port.nil?
@selenium_server_port = Jasmine::find_unused_port
@selenium_pid = fork do
Process.setpgrp
exec "java -jar #{@selenium_jar_path} -port #{@selenium_server_port} > /dev/null 2>&1"
end
puts "selenium started. pid is #{@selenium_pid}"
end
Jasmine::wait_for_listener(@selenium_server_port, "selenium server")
end
def start_servers
start_jasmine_server
start_selenium_server
end
def stop_servers
puts "shutting down the servers..."
Jasmine::kill_process_group(@selenium_pid) if @selenium_pid