Anthony
Anthony

Reputation: 71

How to automatically start Nodered on boot?

I want to automatically start nodered on boot. I'm using a raspberry 3 model B v2.

According to those instructions "https://nodered.org/docs/getting-started/raspberrypi" , I have install and create a flow.

I'm using Node-RED version: v0.20.7 Node.js version: v8.16.0

When I start nodered using node-red-pi --max-old-space-size=256 it's working perfectly.

But now I want to use it as a service and launch it automatically. Following the same instructions, I ran the command sudo systemctl enable nodered.service. The reboot, and nothing happened. Nodered didn't start.

I tried to run it directly as a service using node-red-start, and I got this error message


Starting as a systemd service.
Unit nodered.service entered failed state.
nodered.service holdoff time over, scheduling restart.
Stopping Node-RED graphical event wiring tool...
Starting Node-RED graphical event wiring tool...
Started Node-RED graphical event wiring tool.
/usr/bin/env: node-red-pi: No such file or directory
nodered.service: main process exited, code=exited, status=127/n/a
Unit nodered.service entered failed state.
nodered.service holdoff time over, scheduling restart.
Stopping Node-RED graphical event wiring tool...
Starting Node-RED graphical event wiring tool...
Started Node-RED graphical event wiring tool.
/usr/bin/env: node-red-pi: No such file or directory
nodered.service: main process exited, code=exited, status=127/n/a
Unit nodered.service entered failed state.
nodered.service holdoff time over, scheduling restart.
Stopping Node-RED graphical event wiring tool...
Starting Node-RED graphical event wiring tool...
Started Node-RED graphical event wiring tool.
/usr/bin/env: node-red-pi: No such file or directory
nodered.service: main process exited, code=exited, status=127/n/a
Unit nodered.service entered failed state.
nodered.service holdoff time over, scheduling restart.
Stopping Node-RED graphical event wiring tool...
Starting Node-RED graphical event wiring tool...
Started Node-RED graphical event wiring tool.
/usr/bin/env: node-red-pi: No such file or directory
nodered.service: main process exited, code=exited, status=127/n/a
Unit 
nodered.service entered failed state.
nodered.service holdoff time over, scheduling restart.
Stopping Node-RED graphical event wiring tool...
Starting Node-RED graphical event wiring tool...
nodered.service start request repeated too quickly, refusing to start.
Failed to start Node-RED graphical event wiring tool.
Unit nodered.service entered failed state.

Has someone an idea about this error and how to fix it? There is another way to start nodered automatically?

Upvotes: 2

Views: 5344

Answers (2)

EisenRm
EisenRm

Reputation: 45

I advise you to use pm2 as a watchdog for nodeRed and to monitor its behavior. (it's more than a watchdog, if you want to fiddle)

simply get pm2 from npm:

npm install pm2@latest -g

then run nodeRed using pm2:

pm2 start <PATH to nodered folder> --node-args="--max-old-space-size=128" -- -v

typically the path you are referring to is : /usr/bin/node-red

finally use:

pm2 save

to save the configuration and

pm2 startup

to create a startup script

to manage the process check the commands here: PM2 quick start

Upvotes: 2

Aqil
Aqil

Reputation: 89

I was facing the same problem a while ago. you can use nohup to start it automatically or not to end the session even you close the device.

Just install nohup, and type nohup node-red. If you want to check status, write nohup status in the terminal. for stoping, nohup stop node-red. Enjoy :)

Upvotes: 1

Related Questions