diff --git a/Selenium Grid.iws b/Selenium Grid.iws
index f14b9494..39d68ecc 100644
--- a/Selenium Grid.iws
+++ b/Selenium Grid.iws
@@ -69,16 +69,17 @@
-
+
+
-
+
-
+
@@ -541,16 +542,16 @@
-
+
-
+
-
+
@@ -1885,13 +1886,6 @@
-
-
-
-
-
-
-
@@ -1955,6 +1949,13 @@
+
+
+
+
+
+
+
diff --git a/lib/ruby/file_extensions.rb b/lib/ruby/file_extensions.rb
new file mode 100644
index 00000000..54638b86
--- /dev/null
+++ b/lib/ruby/file_extensions.rb
@@ -0,0 +1,9 @@
+class File
+
+ def self.native_path(path)
+ expanded_path = File.expand_path(path)
+ expanded_path.gsub!('/', '\\') if PLATFORM['win32']
+ expanded_path
+ end
+
+end
diff --git a/lib/ruby/java/classpath.rb b/lib/ruby/java/classpath.rb
new file mode 100644
index 00000000..4fc257aa
--- /dev/null
+++ b/lib/ruby/java/classpath.rb
@@ -0,0 +1,28 @@
+module Java
+
+ class Classpath
+ require 'pathname'
+
+ def initialize(root_dir)
+ @root = root_dir
+ @locations = []
+ self
+ end
+
+ def <<(paths)
+ @locations = (@locations << Dir[@root + '/' + paths]).flatten
+ self
+ end
+
+ def definition
+ @locations.map {|path| File.native_path(path)}.join(self.separator)
+
+ end
+
+ def separator
+ PLATFORM['win32'] ? ";" : ":"
+ end
+
+ end
+
+end
diff --git a/lib/ruby/java/vm.rb b/lib/ruby/java/vm.rb
new file mode 100644
index 00000000..361fb214
--- /dev/null
+++ b/lib/ruby/java/vm.rb
@@ -0,0 +1,31 @@
+module Java
+
+ class VM
+
+ def run(classname, options)
+ command = [ "java" ]
+ command << "-cp \"#{options[:classpath]}\""
+ command << classname
+ command << jvm_properties(options[:properties])
+ command << options[:args].join(' ') if options[:args]
+ command << ">\"#{options[:log_file]}\" 2>&1" if options[:log_file]
+
+ if options[:background ]
+ if PLATFORM['win32']
+ command.unshift("start")
+ else
+ command << "&"
+ end
+ end
+
+ sh command.join(' ')
+ end
+
+ def jvm_properties(property_hash)
+ return "" unless property_hash
+ property_hash.inject([]) {|memo, (name, value)| memo << "-D#{name}=#{value}" }.join(' ')
+ end
+
+ end
+
+end
diff --git a/src/scripts/Rakefile b/src/scripts/Rakefile
index c25731f0..bb56414d 100755
--- a/src/scripts/Rakefile
+++ b/src/scripts/Rakefile
@@ -2,6 +2,9 @@
# Rakefile managing Selenium Grid components
#
require File.dirname(__FILE__) + '/lib/ruby/tcp_socket_extensions'
+require File.dirname(__FILE__) + '/lib/ruby/file_extensions'
+require File.dirname(__FILE__) + '/lib/ruby/java/classpath'
+require File.dirname(__FILE__) + '/lib/ruby/java/vm'
desc "Print help"
task :help do
@@ -85,7 +88,8 @@ end
desc "Stop Hub"
task :'hub:stop' do
- sh "kill `lsof -t -i :4444`"
+ http = Net::HTTP.new("localhost", 4444)
+ http.post('/lifecycle-manager', "action=shutdown")
end
desc "Launch Remote Control"
@@ -95,7 +99,8 @@ end
desc "Stop Remote Control"
task :'rc:stop' do
- sh "kill `lsof -t -i :#{ENV['PORT'] || 5555}`"
+ http = Net::HTTP.new("localhost", ENV['PORT'] || 5555)
+ puts http.post('/selenium-server/driver/', "cmd=shutDown")
end
desc "Launch Remote Control"
@@ -110,8 +115,15 @@ end
desc"Stop Remote Controls. Usage rake rc:stop PORTS=5555-5560"
task :'rc:stop_all' do
- port_range = ENV['PORTS'] || "5000-5020"
- sh "kill `lsof -t -i :#{port_range}`"
+ ports = ENV['PORTS'] || "5000-5020"
+ port_range = Range.new(*ports.split("-"))
+ port_range.each do |port|
+ begin
+ http = Net::HTTP.new("localhost", port)
+ http.post('/selenium-server/driver/', "cmd=shutDown")
+ rescue Exception => e
+ STDERR.puts "Could not properly shutdown remote control #{port} : #{e}"
+ end
end
desc "Launch a Xvnc server"
@@ -141,73 +153,3 @@ def rc_args(options)
args << (options[:selenium_args] || ENV['SELENIUM_ARGS'] || "")
args
end
-
-### To be extracted (eventually) ###
-
-
-
-class File
-
- def self.native_path(path)
- expanded_path = File.expand_path(path)
- expanded_path.gsub!('/', '\\') if PLATFORM['win32']
- expanded_path
- end
-end
-
-module Java
-
- class Classpath
- require 'pathname'
-
- def initialize(root_dir)
- @root = root_dir
- @locations = []
- self
- end
-
- def <<(paths)
- @locations = (@locations << Dir[@root + '/' + paths]).flatten
- self
- end
-
- def definition
- @locations.map {|path| File.native_path(path)}.join(self.separator)
-
- end
-
- def separator
- PLATFORM['win32'] ? ";" : ":"
- end
-
- end
-
- class VM
-
- def run(classname, options)
- command = [ "java" ]
- command << "-cp \"#{options[:classpath]}\""
- command << classname
- command << jvm_properties(options[:properties])
- command << options[:args].join(' ') if options[:args]
- command << ">\"#{options[:log_file]}\" 2>&1" if options[:log_file]
-
- if options[:background ]
- if PLATFORM['win32']
- command.unshift("start")
- else
- command << "&"
- end
- end
-
- sh command.join(' ')
- end
-
- def jvm_properties(property_hash)
- return "" unless property_hash
- property_hash.inject([]) {|memo, (name, value)| memo << "-D#{name}=#{value}" }.join(' ')
- end
-
- end
-
-end