AWS - start automatically

Hi,

I have a instance of node-red running on AWS.

Every time my EC2 gets rebooted Node-red stops, I have followed the instructions on Running on Amazon Web Services : Node-RED

   sudo npm install -g --unsafe-perm pm2
   pm2 start `which node-red` -- -v
   pm2 save
   pm2 startup

I re-run the above and it starts up.

Any suggestions as the why it does not start up on its own?

Kind Regards

Assuming you are using Ubuntu you can use the systemd script to run Node-RED as a service and it will start on boot without pm2

https://nodered.org/docs/getting-started/raspberrypi#autostart-on-boot

It's a Ubuntu instance.

Thanks, I have tried it, not starting up

sudo npm install -g pm2
pm2 start `which node-red` -- -v
pm2 save
pm2 startup

Pay attention to the last command, you will have to execute another command (like: sudo env PATH = $ PATH:/usr/bin/usr/lib/node_modules/pm2/bin/pm2 startup systemd -u ubuntu --hp /home/ubuntu)

You should use the install script on the page I linked to, this will install Node-RED, NodeJS and the systemd script that can be used.

As I said there is no need for PM2 with this method.

image

Personally, I prefer to use PM2, because it also ensures the node-red autorestart (if there is a crash).

I used the PM2, but it does not restart on a EC2 reboot.

I don't know the path you are referring to.

sudo systemctl enable nodered.service

Does not work ether.

PM2 do restart in EC2 reboot. Most likely you are missing something (or you have another problem).