Class: Puppeteer::BrowserRunner::BrowserProcess

Inherits:
Object
  • Object
show all
Defined in:
lib/puppeteer/browser_runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env, executable_path, args) ⇒ BrowserProcess

Returns a new instance of BrowserProcess.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/puppeteer/browser_runner.rb', line 22

def initialize(env, executable_path, args)
  @spawnargs =
    if args && !args.empty?
      [executable_path] + args
    else
      [executable_path]
    end

  stdin, @stdout, @stderr, @thread = Open3.popen3(env, executable_path, *args)
  stdin.close
  @pid = @thread.pid
rescue Errno::ENOENT => err
  raise LaunchError.new(err.message)
end

Instance Attribute Details

#spawnargsObject (readonly)

Returns the value of attribute spawnargs.



48
49
50
# File 'lib/puppeteer/browser_runner.rb', line 48

def spawnargs
  @spawnargs
end

#stderrObject (readonly)

Returns the value of attribute stderr.



48
49
50
# File 'lib/puppeteer/browser_runner.rb', line 48

def stderr
  @stderr
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



48
49
50
# File 'lib/puppeteer/browser_runner.rb', line 48

def stdout
  @stdout
end

Instance Method Details

#disposeObject



43
44
45
46
# File 'lib/puppeteer/browser_runner.rb', line 43

def dispose
  [@stdout, @stderr].each { |io| io.close unless io.closed? }
  @thread.join
end

#killObject



37
38
39
40
41
# File 'lib/puppeteer/browser_runner.rb', line 37

def kill
  Process.kill(:KILL, @pid)
rescue Errno::ESRCH
  # already killed
end