Issue
I'm working on a Raspberry Pi running nextjs (node server) connected with nginx. I tried using x-terminal-emulator ‘/usr/bin/bash -c /home/pi/Desktop/startup.sh’
but many of them didn’t recognize /usr/bin/bash
as a directory and most of them didn’t budge to execute the script. In how many ways can I start my bash script? What is the most useful way possible?
These are the ways that I tried and the errors corresponding to them.
- contrab -e: Didn’t budge to execute the command line
- rc.local: DIdn’t budge to execute the command line
- systemd:
/usr/bin/bash
file or directory doesn’t exist.
I’ve must of been using them incorrectly. If so what is the way to use them?
Solution
This recipe allows you to launch node server at system boot. In this recipe it is assumed that you have a node server running on port 3000.
Steps
- Add node server to the rc.local file
sudo nano /etc/rc.local
Add the following line to the rc.local file
sudo node /home/pi/node_server.js
- Make rc.local executable
sudo chmod +x /etc/rc.local
- Reboot the system
sudo reboot
- Verify that the server is running at boot
sudo netstat –lntp | grep 3000
This should output node server which is running on port 3000.
- Verify that the server is accessible from remote computer
curl -i http://<ip_address>:3000
Answered By - ANISH SAJI KUMAR Answer Checked By - Pedro (WPSolving Volunteer)