Reputation: 31
I have this Puppeteer file I'm trying to run on an Ubuntu server:
var puppeteer = require('puppeteer')
const browser = await puppeteer.launch({
'headless' : true,
"executablePath": "/usr/bin/chromium-browser",
"args": [
'--disable-setuid-sandbox',
'--no-sandbox',
'--disable-gpu',
//'--no-first-run'
]
})
const page = await browser.newPage()
It works well on my computer, but when I try to run it on my server I get the below error. I've read many posts on this topic and looked into the troubleshooting file on Github, but nothing works for me.
How can I resolve this issue with running Puppeteer on an Ubuntu server? I'm using the latest version, Ubuntu 18.04.5 LTS.
root@h2922648:~/Test# node test.js
[0620/162429.725764:ERROR:gpu_init.cc(441)] Passthrough is not supported, GL is swiftshader
DevTools listening on ws://127.0.0.1:36132/devtools/browser/6c0ea0f9-d0a8-4fb8-85b9-61e9a2759b67
Start
[0620/162430.186785:ERROR:platform_thread_posix.cc(148)] pthread_create: Die Ressource ist zur Zeit nicht verfügbar (11)
[0620/162430.187119:FATAL:thread_pool_impl.cc(178)] Check failed: service_thread_.StartWithOptions(std::move(service_thread_options)).
#0 0x55670c3baaa9 base::debug::CollectStackTrace()
#1 0x55670c3260e3 base::debug::StackTrace::StackTrace()
#2 0x55670c337730 logging::LogMessage::~LogMessage()
#3 0x55670c33827e logging::LogMessage::~LogMessage()
#4 0x55670c394f80 base::internal::ThreadPoolImpl::Start()
#5 0x55670f84321f content::ChildProcess::ChildProcess()
#6 0x556711078b03 content::RenderProcess::RenderProcess()
#7 0x556711078423 content::RenderProcessImpl::RenderProcessImpl()
#8 0x556711078abb content::RenderProcessImpl::Create()
#9 0x5567117ddce3 content::RendererMain()
#10 0x55670c2c267c content::RunZygote()
#11 0x55670c2c390e content::ContentMainRunnerImpl::Run()
#12 0x55670c2c0f7d content::RunContentProcess()
#13 0x55670c2c191d content::ContentMain()
#14 0x55670c3203b6 headless::(anonymous namespace)::RunContentMain()
#15 0x55670c32011e headless::RunChildProcessIfNeeded()
#16 0x55670c31e9f5 headless::HeadlessShellMain()
#17 0x556709204264 ChromeMain
#18 0x7f3654e01bf7 __libc_start_main
#19 0x5567092040aa _start
Received signal 6
#0 0x55670c3baaa9 base::debug::CollectStackTrace()
#1 0x55670c3260e3 base::debug::StackTrace::StackTrace()
#2 0x55670c3ba5d1 base::debug::(anonymous namespace)::StackDumpSignalHandler()
#3 0x7f365986c980 (/lib/x86_64-linux-gnu/libpthread-2.27.so+0x1297f)
#4 0x7f3654e1efb7 gsignal
#5 0x7f3654e20921 abort
#6 0x55670c3b9895 base::debug::BreakDebugger()
#7 0x55670c337b57 logging::LogMessage::~LogMessage()
#8 0x55670c33827e logging::LogMessage::~LogMessage()
#9 0x55670c394f80 base::internal::ThreadPoolImpl::Start()
#10 0x55670f84321f content::ChildProcess::ChildProcess()
#11 0x556711078b03 content::RenderProcess::RenderProcess()
#12 0x556711078423 content::RenderProcessImpl::RenderProcessImpl()
#13 0x556711078abb content::RenderProcessImpl::Create()
#14 0x5567117ddce3 content::RendererMain()
#15 0x55670c2c267c content::RunZygote()
#16 0x55670c2c390e content::ContentMainRunnerImpl::Run()
#17 0x55670c2c0f7d content::RunContentProcess()
#18 0x55670c2c191d content::ContentMain()
#19 0x55670c3203b6 headless::(anonymous namespace)::RunContentMain()
#20 0x55670c32011e headless::RunChildProcessIfNeeded()
#21 0x55670c31e9f5 headless::HeadlessShellMain()
#22 0x556709204264 ChromeMain
#23 0x7f3654e01bf7 __libc_start_main
#24 0x5567092040aa _start
r8: 0000000000000000 r9: 00007fffaf96c090 r10: 0000000000000008 r11: 0000000000000246
r12: 00000fa200488640 r13: 00007fffaf96c2f0 r14: 00000fa200488650 r15: aaaaaaaaaaaaaaaa
di: 0000000000000002 si: 00007fffaf96c090 bp: 00007fffaf96c2e0 bx: 00007fffaf96cb20
dx: 0000000000000000 ax: 0000000000000000 cx: ffffffffffffffff sp: 00007fffaf96c090
ip: 00007f3654e1efb7 efl: 0000000000000246 cgf: 0000000000000033 erf: 0000000000000000
trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000
[end of stack trace]
Upvotes: 2
Views: 11741
Reputation: 198
So here I am posting a working code.
In the comments, I have mentioned that what was missing in your code and why we need it.
Make sure that you following already installed in your ubuntu machine:
apt-get install -y curl google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1
It was freezing because we have to close the browser after everything.
I have added dumpio also, it will enable the debug mode.
var puppeteer = require('puppeteer-core')
var adresse = "https://www.google.de/"
async function test() {
try {
const browser = await puppeteer.launch({
"dumpio": true,
"headless": true,
"executablePath": '/usr/bin/chromium-browser',
"args": [
'--disable-setuid-sandbox',
'--no-sandbox',
'--disable-gpu',
]
})
console.log("Start");
const page = await browser.newPage();
console.log("1");
await page.goto(adresse, { waitUntil: ['load', 'networkidle0'] }); // WAIT for the page load finish. Provide wait options, you can read moe about it in documentation.
console.log("2");
console.log(page);
await page.screenshot({path: 'buddy-screenshot.png'}); // WHAT you wanted to do with the page. You can take Screenshot or generate pdf.
await page.close(); // After job done close the page
await browser.close(); // IMPORTANT: you have to shutdown the browser in order to proceed with the results.
} catch (error) {
console.log(error)
}
}
await test(); // For safe side wait for it.
Upvotes: 2