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.



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

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.



54
55
56
# File 'lib/puppeteer/browser_runner.rb', line 54

def spawnargs
  @spawnargs
end

#stderrObject (readonly)

Returns the value of attribute stderr.



54
55
56
# File 'lib/puppeteer/browser_runner.rb', line 54

def stderr
  @stderr
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



54
55
56
# File 'lib/puppeteer/browser_runner.rb', line 54

def stdout
  @stdout
end

Instance Method Details

#disposeObject



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

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

#killObject



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

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