samsonmking / epaper.js

Node.js library for easily creating an ePaper display on a Raspberry PI using HTML and Javascript.
MIT License
761 stars 48 forks source link

Run application as root #50

Closed craigtb closed 2 years ago

craigtb commented 2 years ago

Im getting this error when running my epaper application as root. Looks like a puppeteer issue and there is a flag to pass in. Where would i add this flag? or is there another way to make this work?

pi@raspberrypi:~/epaper $ sudo node server.js
/***********************************/
Current environment: Raspbian
set wiringPi lib success !!!
/***********************************/
/home/pi/node_modules/puppeteer-core/lib/launcher/BrowserRunner.js:189
            reject(new Error([
                   ^

Error: Failed to launch the browser process!
dpkg-query: no packages found matching bluealsa
[0107/204416.647753:ERROR:zygote_host_impl_linux.cc(90)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.

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

    at onClose (/home/pi/node_modules/puppeteer-core/lib/launcher/BrowserRunner.js:189:20)
    at Interface.<anonymous> (/home/pi/node_modules/puppeteer-core/lib/launcher/BrowserRunner.js:179:65)
samsonmking commented 2 years ago

Hi @craigtb, I believe it's generally not advised to run Chromium as root for security reasons. It is possible, but you need to pass additional flags into the Chromium instance. It's not something we currently support as a configuration option for epaper.js, but it is something we could consider.

Do you mind if I ask why you're running as root? Is there a specific problem you're trying to solve?

craigtb commented 2 years ago

@samsonmking Thanks for getting back to me. IO understand. What I am trying to do is build a cron job to start the server. It doesnt seem to start when I run it as a regular user, but sudo throws an error. I was able to dig in to your code and add the --no-sandbox flag and it did start working.

Any other options other than cron? The goal is to build a process that runs on startup and starts the application.

samsonmking commented 2 years ago

@craigtb you might be interested in giving pm2 a try. I've spoken with other users who have successfully used to it run epaper.js as a daemon.

Another option might be setting up a systemd service. You won't need to install any additional software, but it is a bit more involved.

craigtb commented 2 years ago

ill give that a look. thanks!