Installation node environment will not go into details, there are many online tutorials, it is very simple.
Acting on a blog describes nodejs with nginx. This one is the use of pm2 automatically restart nodejs.
What is pm2? As the official website, pm2 is nodejs advanced production process manager. Such as performance monitoring, automatic restart, load balancing and so on.
More tutorials on pm2, please venue pm2 official documents
1. Make sure that the node
2. Install pm2
pm2 -g install npm
3. Use pm2 boot server files
* Please note that the start address behind changed their address file
Start /api/server.js --name = pm2 "nodeServer"
4. pm2 to the boot
Startup PM2
5. The next can test, reboot the system
shutdown -r now
after the system restart successfully, you will find the interface can still access
pm2 list # view the process pm2 stop / reload / restart / delete all # stop / reload / restart / delete all processes pm2 stop / reload / restart / delete 0 # stop / reload / restart / delete pm2 process list process 0 the process pm2 logs [--raw] # show all processes log pm2 flush # Clear all log files pm2 reloadLogs # reload all logs