Sha256: 0c66537603ff1c9c156880e3900b6e32c7582e97146ca16e350c667fd82fbf79
Contents?: true
Size: 623 Bytes
Versions: 3
Compression:
Stored size: 623 Bytes
Contents
# frozen_string_literal: true module Postdoc class ChromeProcess attr_reader :pid, :port def initialize(port: Random.rand(65_535 - 1024), **_options) @port = port @pid = Process.spawn "chrome --remote-debugging-port=#{port} --headless", out: File::NULL, err: File::NULL end def alive? @alive ||= test_socket! rescue Errno::ECONNREFUSED false end def kill Process.kill 'KILL', pid Process.wait pid end def client Client.new port end private def test_socket! TCPSocket.new('localhost', port) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
postdoc-0.3.6 | lib/postdoc/chrome_process.rb |
postdoc-0.3.5 | lib/postdoc/chrome_process.rb |
postdoc-0.3.4 | lib/postdoc/chrome_process.rb |