Skip to content

Commit 6092daa

Browse files
author
Bob Cotton
committed
Teach the Rakefile how to use the grid_configuration.yml
If you've changed the default port the hub starts on using the grid_configuration.yml, the Rakefile should honor that. Also added a missing require 'net/http', as this was failing on some of our machines.
1 parent 7b2df55 commit 6092daa

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/scripts/Rakefile

+12-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ require File.dirname(__FILE__) + '/lib/ruby/file_extensions'
66
require File.dirname(__FILE__) + '/lib/ruby/java/classpath'
77
require File.dirname(__FILE__) + '/lib/ruby/java/vm'
88

9+
require 'yaml'
10+
require 'net/http'
11+
912
desc "Print help"
1013
task :help do
1114
puts <<-EOS
@@ -65,7 +68,7 @@ task :'all:start' do
6568
ENV['BACKGROUND'] = "true"
6669
Rake::Task[:'hub:start'].invoke
6770
puts "Waiting for Hub to come up..."
68-
TCPSocket.wait_for_service :host => "localhost", :port => 4444
71+
TCPSocket.wait_for_service :host => "localhost", :port => hub_port
6972
Rake::Task[:'rc:start_all'].invoke
7073
end
7174

@@ -88,8 +91,8 @@ end
8891

8992
desc "Stop Hub"
9093
task :'hub:stop' do
91-
http = Net::HTTP.new("localhost", 4444)
92-
http.post('/lifecycle-manager', "action=shutdown")
94+
http = Net::HTTP.new("localhost", hub_port)
95+
http.post('/lifecycle-manager', "action=shutdown") rescue nil
9396
end
9497

9598
desc "Launch Remote Control"
@@ -149,8 +152,13 @@ def rc_args(options)
149152
args = []
150153
args << "-host" << (options[:host] || ENV['HOST'] || "localhost")
151154
args << "-port" << options[:port]
152-
args << "-hubUrl" << (options[:hub_url] || ENV['HUB_URL'] || 'http://localhost:4444')
155+
args << "-hubUrl" << (options[:hub_url] || ENV['HUB_URL'] || "http://localhost:#{hub_port}")
153156
args << "-env '#{options[:environment] || ENV['ENVIRONMENT'] || "*chrome"}'"
154157
args << (options[:selenium_args] || ENV['SELENIUM_ARGS'] || "")
155158
args
156159
end
160+
161+
def hub_port
162+
@config ||= YAML.load(File.read(File.dirname(__FILE__) + "/grid_configuration.yml"))
163+
@config["hub"]["port"].to_i
164+
end

0 commit comments

Comments
 (0)