please help me out here.
I have a fresh ubuntu server 22.04 setup with node (v18.12.1) / express, and PM2 as the process manager.
I have Puppeteer installed and the Chromium browser, which is working fine. I use it to generate high quality PNG files for personal use.
The problem is, when I reboot the server, PM2 successfully starts the node app, so my website is accessible. I can successfully ping it and get a response, so the web app is working fine after a reboot.
The problem is that (after a reboot) Puppeteer is unable to launch the browser if I send a request to my web app and say, hey, give me a screenshot of this. I get the following error:
Error: Failed to launch the browser process!
/usr/bin/chromium-browser: 12: xdg-settings: not found
2022/12/08 00:36:47.167545 cmd_run.go:1055: WARNING: cannot start document portal: dial unix
/run/user/1001/bus: connect: no such file or directory
/system.slice/pm2-sammy.service is not a snap cgroup
Now, say I reboot the server, and ssh into it as the user sammy (which everything is installed and should be running as - pm2 startup saved in user /home.sammy etc.) and if I ask for the same screenshot, now everything is working as expected.
It looks like merely ssh'ing into the server triggers something then everything is working fine. I can't figure out what I'm missing. By the way, I've got this working fine on a local Vagrant machine.
I think on reboot there is no session running under the user sammy hence it works after ssh'ing in because a session is started?