set process group id on spawned servers to allow kill by process group id later.

turn off selenium spew.
This commit is contained in:
Erik Hanson & Christian Williams 2009-07-14 10:35:53 -07:00
parent 7da72062b3
commit 2c81941567

View File

@ -144,13 +144,15 @@ module Jasmine
@selenium_server_port = Jasmine::find_unused_port @selenium_server_port = Jasmine::find_unused_port
@selenium_pid = fork do @selenium_pid = fork do
exec "java -jar #{@selenium_jar_path} -port #{@selenium_server_port}" Process.setpgrp
exec "java -jar #{@selenium_jar_path} -port #{@selenium_server_port} &> /dev/null"
end end
puts "selenium started. pid is #{@selenium_pid}" puts "selenium started. pid is #{@selenium_pid}"
@jasmine_server_pid = fork do @jasmine_server_pid = fork do
Process.setpgrp
Jasmine::SimpleServer.start(@jasmine_server_port, @spec_files, @dir_mappings) Jasmine::SimpleServer.start(@jasmine_server_port, @spec_files, @dir_mappings)
sleep(100000) exit! 0
end end
puts "jasmine server started. pid is #{@jasmine_server_pid}" puts "jasmine server started. pid is #{@jasmine_server_pid}"
@ -158,10 +160,14 @@ module Jasmine
wait_for_listener(@jasmine_server_port, "jasmine server") wait_for_listener(@jasmine_server_port, "jasmine server")
end end
def kill_process_group(process_group_id, signal="TERM")
Process.kill signal, -process_group_id # negative pid means kill process group. (see man 2 kill)
end
def stop_servers def stop_servers
puts "shutting down the servers..." puts "shutting down the servers..."
Process.kill 15, @selenium_pid if @selenium_pid kill_process_group(@selenium_pid) if @selenium_pid
Process.kill 15, @jasmine_server_pid if @jasmine_server_pid kill_process_group(@jasmine_server_pid) if @jasmine_server_pid
end end
def run def run