In a previous article I explained how you can install Node-RED on your Ubuntu server. Quite a few people are wondering how you can configure your server to start Node-RED automatically on system boot. That’s what this article is all about: start Node-RED as a service when the server starts.
The procedure is simple, as the Node-RED team is providing us the startup scripts.
sudo wget https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/nodered.service -O /lib/systemd/system/nodered.service
sudo wget https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/node-red-start -O /usr/bin/node-red-start
sudo wget https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/node-red-stop -O /usr/bin/node-red-stop
sudo chmod +x /usr/bin/node-red-st*
sudo systemctl daemon-reload
Unfortuntely we’re not ready yet. The script are written for a Raspberry Pi system. We need to alter a script to make sure Node-RED runs an axisting user on the server.
sudo nano /lib/systemd/system/nodered.service
Find the following lines and change the user and group to an existing user.
Now the only thing left is to enable the service.
sudo systemctl enable nodered.service
That’s it! Restart your server and verify Node-RED is starting on system boot.