Restart node-red automatically

Hello,

I want that if my node-red stops for some reason that it can be restarted by itself. I was thinking in using a python script with "os.system()" and then using "crontab -e" to init it in the start of the device.

I am using a Raspberry Pi 3.

If you can attach me some code or instructions I would really appreciate it.

Thank you!

If you start node-red using the systemd method (systemctl, etc.) then you can use that to restart it on certain conditions. This would be the “correct” way to do it as well. You just need to edit the service file. I’ll let you Google on howto.

So, if I use "systemctl" to init node-red if node-red fails, does it reboot by itself?

You will need to change the node-red.service file to enable it to restart if it stops for some reason.

If you installed using the recommended node red install script then the systemd script will automatically restart node-red if it crashes.

1 Like

So if y use the "Starting Node-RED on boot" part of the following link: "https://nodered.org/docs/getting-started/running". If node-red crashes, will it restart automatically?

You should have followed these instructions for a pi.
https://nodered.org/docs/hardware/raspberrypi
You can run the upgrade script there to bring everything up to date. If you follow those instructions including the section on running from boot then yes, it will restart if node red crashes

Ok. Thank you!