Ubuntu boot from the start to set in NodeRed

Boxer's new crown burning rampant. No sound country, then a closed-door study mqtt, build NodeRed, then it can not be started from the boot, so then I started struggling with obtaining the solution, we had this in mind.

problem analysis:

In fact Nodered also a nodejs process, so only need to use nodejs of pm2 process management tools can make Nodered the post. What is pm2 own Baidu, no nonsense.

 

Solution:

Installation pm2:

npm install pm2 -gd

Use PM2 start Node-red:

pm2 start node-red

View a list of items at startup:

pm2 ls

If successfully loaded appears similar to the following:

root@:~# pm2 ls
┌─────┬─────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id  │ name        │ namespace   │ version │ mode    │ pid      │ uptime │ ?    │ status    │ cpu      │ mem      │ user     │ watching │
├─────┼─────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0   │ node-red    │ default     │ N/A     │ fork    │ 3772     │ 22h    │ 1    │ online    │ 0.2%     │ 123.3mb  │ root     │ disabled │
└─────┴─────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘

Set pm2 to process from the start:

sudo pm2 startup

Note: After this command is executed, the system will create a startup script, on Ubuntu18.04 will automatically add a soft link, if it is other versions, you may need to perform in accordance with the output of the command prompt. Other versions may output commands, copy follow the prompts to enter the bash and enter on it, in fact, this step is to add a service system from the start.

Save pm2 modify the content:

sudo pm2 save

If you would with fast hardware stuff that does not require nodered this only if we do not know in front of the back-end soft doll with things only when, Ok closed nodered self-start function directly pm2 inside.

The removal process:

pm2 delete nodered

 

Finally, finally! Wuhan Come on! Come on, dear Davari's who!

 

Published 21 original articles · won praise 12 · views 10000 +

Guess you like

Origin blog.csdn.net/Argon_Ghost/article/details/104481455