I have a little NodeJS app that accesses to a MongoDB database and takes some data in order to be displayed in an index.html file. I run it on an Ubuntu Mate 18.04.2 OS on a Raspberry Pi B+
I run the NodeJS app with the line:
node /routeofmyapp/index.js
Then the server starts up and I can go to the index.html file and check the displayed data.
The next thing I want to do in the project is executed automatically the index.js
at the start-up of the system without having to launch the console terminal.
How can I do it?
Thanks in advance.
Edit sudo nano /home/pi/.bashrc
file.
Go to the last line of the script and add:
echo Running at boot
sudo node /routeofmyapp/index.js
Then save and reboot RPi:
sudo reboot