Puppeteer 服务器启动失败以及安装慢问题

March 01, 2020

问题一

服务启动失败,日志记录如下

$ less /root/logs/master-stderr.log
2020-03-05 15:09:28,483 ERROR 98893 [-/127.0.0.1/-/0ms GET /] nodejs.Error: Failed to launch chrome!
/data/frontend/fe-node-staticize-render/node_modules/puppeteer/.local-chromium/linux-686378/chrome-linux/chrome: error while loading shared libraries: libXss.so.1: cannot open shared object file: No such file or directory


TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md

/data/frontend/fe-node-staticize-render/node_modules/puppeteer/.local-chromium/linux-686378/chrome-linux/chrome: error while loading shared libraries: libXss.so.1: cannot open shared object file: No such file or directory


TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md

    at onClose (/data/frontend/fe-node-staticize-render/node_modules/puppeteer/lib/Launcher.js:348:14)
    at Interface.helper.addEventListener (/data/frontend/fe-node-staticize-render/node_modules/puppeteer/lib/Launcher.js:337:50)
    at Interface.emit (events.js:187:15)
    at Interface.close (readline.js:379:8)
    at Socket.onend (readline.js:157:10)
    at Socket.emit (events.js:187:15)
    at endReadableNT (_stream_readable.js:1085:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

通过 google 找到原因:https://github.com/atom/atom/issues/13176,在服务器中安装如下依赖解决:

$ yum install libXScrnSaver

问题二

解决问题一后,服务启动失败,日志记录如下 参考:https://github.com/puppeteer/puppeteer/issues/3080

/data/frontend/fe-node-staticize-render/node_modules/puppeteer/.local-chromium/linux-686378/chrome-linux/chrome: /lib64/libnss3.so: version `NSS_3.22' not found (required by /data/frontend/fe-node-staticize-render/node_modules/puppeteer/.local-chromium/linux-686378/chrome-linux/chrome)


TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md

    at onClose (/data/frontend/fe-node-staticize-render/node_modules/puppeteer/lib/Launcher.js:348:14)
    at Interface.helper.addEventListener (/data/frontend/fe-node-staticize-render/node_modules/puppeteer/lib/Launcher.js:337:50)
    at Interface.emit (events.js:187:15)
    at Interface.close (readline.js:379:8)
    at Socket.onend (readline.js:157:10)
    at Socket.emit (events.js:187:15)
    at endReadableNT (_stream_readable.js:1085:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

升级以下依赖

$ yum update nss

问题三

如果以上依赖已经安装还是无法启动,则安装以下依赖 参考:https://segmentfault.com/a/1190000011382062

$ yum install pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXtst.x86_64 cups-libs.x86_64 libXScrnSaver.x86_64 libXrandr.x86_64 GConf2.x86_64 alsa-lib.x86_64 atk.x86_64 gtk3.x86_64 -y

问题四

安装失败问题 参考:https://brickyang.github.io/2019/01/14/%E5%9B%BD%E5%86%85%E4%B8%8B%E8%BD%BD%E5%AE%89%E8%A3%85-Puppeteer-%E7%9A%84%E6%96%B9%E6%B3%95/

$ PUPPETEER_DOWNLOAD_HOST=https://storage.googleapis.com.cnpmjs.org npm install puppeteer