I know there are a lot of answers to this question but none have worked for me and I've been at it for something like six hours... Most of the answers also look like they're years out of date.
I am trying to open an lxterminal when my Raspberry Pi 3B+ opens, have it run a node server.js file, and then keep that terminal open (because the program requires it).
I've tried editing the autostart files at both
/etc/xdg/lxsession/LXDE/autostart and /home/pi/.config/lxsession/LXDE-pi/autostart
Even just trying to run @lxterminal from either of those doesn't work.
I have successfully been able to get the other half of this project running, which is to open localhost in a browser on bootup, by putting a command in autostart at /etc/xdg/lxsession/LXDE/autostart
Basically, my program will crash if I don't keep the terminal open, and I want to run this in headless mode because it's a portable NFC-scanning application that I'm using for a game that is receiving data from one serial port, piping it to the webpage to play audio and parse some text, then sending that text back over socket.io to display on a tiny LCD screen.
Thanks for your help!
Edited To Add: I tried pm2 and it didn’t work, unfortunately. I spent a few hours today trying to debug but in a nutshell the command would run once then fail, and not appear in the pm2 process list (but the port remained blocked). It’s possible there’s something I’m missing.