Sha256: 5f1a95775e8355de832bd184355f061e62b20831c7c05ce9f66d1e25467caeb0
Contents?: true
Size: 1.98 KB
Versions: 2
Compression:
Stored size: 1.98 KB
Contents
#!/usr/local/bin/ruby -w require "selenium/client/driver" module Statt class Motor attr_accessor :rc def initialize(options={}) options = { :hub_host => "localhost", :hub_port => 4444, :rc_options => {:host => "localhost", :port => 5555 } }.merge(options) hub_options = { :host => options[:hub_host], :port => options[:hub_port] } # Start up Hub server in its own thread. @hub_thread = Thread.new do Thread.current[:hub] = SGrid::Hub.new(hub_options) Thread.current[:hub].start self.pass end @hub_thread[:hub].wait_until_up_and_running # Start up the RC Servers, each within their own thread. @rc_threads = [] @rc_threads << Thread.new do rc_options = options[:rc_options] if options[:rc_options].is_a?(Hash) Thread.current[:server] = SGrid::RemoteControl.new(rc_options) Thread.current[:server].start if rc_options[:host] == "localhost" elsif options[:rc_options].is_a?(Array) rc_options.each do |rc_option| Thread.current[:server] = SGrid::RemoteControl.new(rc_option) Thread.current[:server].start if rc_option[:host] == "localhost" end else raise Exception, "there was a problem starting the rc server(s)", caller end self.pass end end def stop Thread.new { shutdown_hub } Thread.new { shutdown_rcs } puts "Shutting down all servers " end def shutdown_hub @hub_thread[:hub].shutdown puts "." end def shutdown_rcs @rc_threads.each do |thr| thr[:server].shutdown puts "." end end # def start_hub # end # # def start_rcs # end private def hub @hub_thread[:hub] end def rc_servers @rc_threads.map {|thr| thr[:server] } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
statt-0.0.4 | lib/statt/motor.rb |
statt-0.0.3 | lib/statt/motor.rb |