Unitech / pm2

Node.js Production Process Manager with a built-in Load Balancer.
https://pm2.keymetrics.io/docs/usage/quick-start/
Other
41.39k stars 2.61k forks source link

Cannot join mount namespace of pid 1: Operation not permitted #5859

Open vishnuc opened 2 months ago

vishnuc commented 2 months ago

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, it's working fine.

When I do that via forever in ssh, pm2 start script.js, or when I do via PHP like below

<?php
// Define the command
$command = "pm2  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.