3

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 are 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 keep that server running (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!

Edit: 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.

Youssof
  • 135
  • 10

1 Answers1

3

I found the solution after all. I used pm2 after all. The quick start suggested at the start of the pm2 documentation will not work. Follow the detailed instructions instead, which amount to:

  1. Install pm2 for node (npm install -g pm2)
  2. Type “pm2 startup” into the command line
  3. Paste in the resulting command as instructed.
  4. Change directories to where your app exists.
  5. Type “pm2 start filename.js”
  6. Type “pm2 save”