Module: Applitools::Connectivity::UniversalServer
- Extended by:
- UniversalServer
- Included in:
- UniversalServer
- Defined in:
- lib/applitools/universal_sdk/universal_server.rb
Constant Summary collapse
- DEFAULT_SERVER_IP =
'127.0.0.1'- DEFAULT_SERVER_PORT =
21077
Instance Method Summary collapse
- #check_or_run(ip = DEFAULT_SERVER_IP, port = DEFAULT_SERVER_PORT) ⇒ Object
- #confirm_is_up(ip, port, attempt = 1) ⇒ Object
- #run ⇒ Object
Instance Method Details
#check_or_run(ip = DEFAULT_SERVER_IP, port = DEFAULT_SERVER_PORT) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/applitools/universal_sdk/universal_server.rb', line 30 def check_or_run(ip = DEFAULT_SERVER_IP, port = DEFAULT_SERVER_PORT) server_uri = "#{ip}:#{port}" socket_uri = "ws://#{server_uri}/eyes" begin TCPSocket.new(ip, port) msg = "Connect to #{server_uri}" rescue Errno::ECONNREFUSED run confirm_is_up(ip, port) msg = "Connect to #{server_libname} : #{filename}" end Applitools::EyesLogger.logger.debug(msg) if ENV['APPLITOOLS_SHOW_LOGS'] socket_uri end |
#confirm_is_up(ip, port, attempt = 1) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/applitools/universal_sdk/universal_server.rb', line 20 def confirm_is_up(ip, port, attempt = 1) raise 'Universal server unavailable' if (attempt === 16) begin TCPSocket.new(ip, port) rescue Errno::ECONNREFUSED sleep 1 confirm_is_up(ip, port, attempt + 1) end end |
#run ⇒ Object
14 15 16 17 18 |
# File 'lib/applitools/universal_sdk/universal_server.rb', line 14 def run raise 'Universal server unrecognized' unless find_server_file? pid = spawn(filepath, '--singleton --lazy', [:out, :err] => ["log", 'w']) Process.detach(pid) end |