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.



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

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

  popen3_args = args || []
  popen3_args << { pgroup: true } unless Puppeteer.env.windows?
  stdin, @stdout, @stderr, @thread = Open3.popen3(env, executable_path, *popen3_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.



51
52
53
# File 'lib/puppeteer/browser_runner.rb', line 51

def spawnargs
  @spawnargs
end

#stderrObject (readonly)

Returns the value of attribute stderr.



51
52
53
# File 'lib/puppeteer/browser_runner.rb', line 51

def stderr
  @stderr
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



51
52
53
# File 'lib/puppeteer/browser_runner.rb', line 51

def stdout
  @stdout
end

Instance Method Details

#disposeObject



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

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

#killObject



40
41
42
43
44
# File 'lib/puppeteer/browser_runner.rb', line 40

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