How to make node-red run 24/7 on Raspberry Pi

Viewed 45

I want to host node-red 24/7 on Raspberry Pi. Something was running it constantly, then, the power had gone out, then it came back. But, then, the data was not coming. I want the node-red to run constantly (at least when the raspberry pi is running). I tried making an .SH file to make it constantly run, here is the code:

node-red

that is the command prompt line to run node-red.

That did not work, is there something that I can do about this?

2 Answers

What you're looking for is a process manager, there are many process managers available each with their own features.

Natively many linux distributions support this functionality via a system called systemd also called an init system.

Docker as a system is also an option but this may be excessive for your use-case.


Some popular process manager applications are:

  1. supervisord
  2. PM2

Additional reading:

A supervisord tutorial on Digital Ocean by Alex Garnett

A systemd tutorial on Digital Ocean by Justin Ellingwood

The node-red install instructions for raspberry pi cover the in the running as a service section

https://nodered.org/docs/getting-started/raspberrypi#running-as-a-service

It is most likely that you had used node-red-start to start Node-RED as a service, but you had not completed the latter step to enable the service to start on boot.

Autostart on boot

If you want Node-RED to run when the Pi is turned on, or re-booted, you can enable the service to autostart by running the command:

sudo systemctl enable nodered.service

To disable the service, run the command:

sudo systemctl disable nodered.service
Related