Class: Applitools::EyesUniversal::UniversalServerControl
- Inherits:
-
Object
- Object
- Applitools::EyesUniversal::UniversalServerControl
- Includes:
- Singleton
- Defined in:
- lib/applitools/eyes_universal/universal_server_control.rb
Constant Summary collapse
- DEFAULT_SERVER_IP =
'127.0.0.1'
- DEFAULT_SERVER_HOST =
'localhost'
- EXECUTABLE_FILEPATH =
Applitools::EyesUniversal::UniversalServerGemFinder.executable_filepath
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ UniversalServerControl
constructor
A new instance of UniversalServerControl.
- #new_server_socket_connection ⇒ Object
- #server_port ⇒ Object
- #server_running? ⇒ Boolean
- #stop_server ⇒ Object
-
#to_s ⇒ Object
for test & debug.
Constructor Details
#initialize ⇒ UniversalServerControl
Returns a new instance of UniversalServerControl.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/applitools/eyes_universal/universal_server_control.rb', line 21 def initialize @control_pipe = nil @port_pipe = nil @usdk_pid = nil @monitoring_thread = nil @port = nil @mask_log = self.class.instance_variable_get(:@mask_log) start_server_with_pipe @sockets = [] end |
Class Method Details
.configure(mask_log = nil) ⇒ Object
16 17 18 |
# File 'lib/applitools/eyes_universal/universal_server_control.rb', line 16 def configure(mask_log = nil) @mask_log = mask_log end |
Instance Method Details
#new_server_socket_connection ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/applitools/eyes_universal/universal_server_control.rb', line 36 def new_server_socket_connection begin # socket = TCPSocket.new(DEFAULT_SERVER_IP, @port) socket = Addrinfo.tcp(DEFAULT_SERVER_HOST, @port).connect @sockets.push(socket) socket rescue Errno::ECONNREFUSED => e puts e nil end end |
#server_port ⇒ Object
32 33 34 |
# File 'lib/applitools/eyes_universal/universal_server_control.rb', line 32 def server_port @port end |
#server_running? ⇒ Boolean
48 49 50 51 52 |
# File 'lib/applitools/eyes_universal/universal_server_control.rb', line 48 def server_running? return false if @monitoring_thread.nil? monitoring_result = @monitoring_thread.join(1) monitoring_result.nil? end |
#stop_server ⇒ Object
54 55 56 57 58 59 |
# File 'lib/applitools/eyes_universal/universal_server_control.rb', line 54 def stop_server return if @control_pipe.nil? @control_pipe.close_write @sockets.each {|socket| socket.close unless socket.closed? } sleep(1) end |
#to_s ⇒ Object
for test & debug
61 62 63 |
# File 'lib/applitools/eyes_universal/universal_server_control.rb', line 61 def to_s # for test & debug "SDKServer(port=#{@port}; pid=#{@usdk_pid})" end |