I have simple puppeteer script in nodejs like below
const puppeteer = require("puppeteer");
(async () => {
const browser = await puppeteer.launch({
headless: true,
executablePath: "/snap/bin/chromium",
args: ["--no-sandbox", "--disable-setuid-sandbox"],
});
const page = await browser.newPage();
await page.goto("https://google.com");
//get screenshot
await page.screenshot({ path: "app4test.png" });
})();
when i ssh to my user and run node script.js , its working fine
When i do that via forever in ssh .. forever script.js , its working fine..
but when i do via php ,
<?php
// Define the command
$command = "forever start /home/example.com/app4test.js";
// Execute the command
$output = exec($command);
// Output the result
echo "<pre>$output</pre>";
?>
I get below error
(Use `node --trace-warnings ...` to show where the warning was created)
/home/example.com/node_modules/@puppeteer/browsers/lib/cjs/launch.js:310
reject(new Error([
^
Error: Failed to launch the browser process!
cannot join mount namespace of pid 1: Operation not permitted
TROUBLESHOOTING: https://pptr.dev/troubleshooting
at Interface.onClose (/home/tradingtoolx.com/node_modules/@puppeteer/browsers/lib/cjs/launch.js:310:24)
at Interface.emit (node:events:531:35)
at Interface.close (node:internal/readline/interface:528:10)
at Socket.onend (node:internal/readline/interface:254:10)
at Socket.emit (node:events:531:35)
at endReadableNT (node:internal/streams/readable:1696:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Node.js v20.15.0
{"level":"error","message":"Forever detected script exited with code: 1"}
also when I do this via pm2 , i get the same above error from ssh as well as php script , I asked this to chatgpt , claude and gemini , none seems to help.I will open bounty soon as time starts as I wasted 2 days.Thank you.