我想在装有Ubuntu的Digital Ocean服务器中使用headless = false
运行puppeteer。
当我进入digitalocean.com上的Digital Ocean控制台时,它可以正常运行(我将ubuntu-desktop作为GUI,实际上会弹出铬并开始在GUI中运行)。
但是,当我SSH进入控制台并尝试运行相同的程序时,该程序将运行,直到命中puppeteer脚本,并且从puppeteer收到以下错误消息:
Error: Failed to launch the browser process!
Unable to open X display.
NaCl helper process running without a sandbox!
Most likely you need to configure your SUID sandbox correctly
这是我的操纵up配置中的内容:
import puppeteer from "puppeteer";
export const getBrowser = async () => {
const browser = await puppeteer.launch({
headless: false,
args: [
"--no-sandbox",
"--disable-setuid-sandbox",
"--window-size=1600,1200",
],
defaultViewport: null,
});
return browser;
};
我玩过移除--no-sandbox
和--disable-setuid-sandbox
的游戏,但这并不能解决问题。
如果您问自己“他们为什么要这么做?” -这主要是因为我发现我正在挖掘的网站在处于呆滞状态时往往很少注意到(我想我可以回到秘密行动者那里了)。
答案 0 :(得分:0)
我有同样的问题。我解决了一半。我在终端中启用了X11转发,现在一切启动。但是,我仍然在努力,因为我想在我的服务器上自动运行头脚本,而又不干扰我,现在我正在考虑可以实现此目的的方法。