Pm2 instruction description

PM2 is a port service daemon tool, which can centrally manage all PM2 started projects on the host, including port information, project information, and run logs, etc., convenient and easy to manage. 1. Start the project

1, NPM run start pm2 start NPM –name “my-nuxt” — run start

1, node app.js pm2 start app.js –name “my-node”

. 2. Manage projects

Id Name Mode restart Status CPU Memory 0 node-API fork 0 online 0% 48.4 MB 2 Wangcong -blog fork 0 online 0% 31.7 MB 1 Wangcong -nuxt fork 0 online 0% 32.3 MB 4 Zoujuan fork 1 online 0% 3.5 MB pm2 list Pm2 stop id/name # stop id/name pm2 del id/name # Delete id/name pm2 log Pm2 show id/name show id/name Ii. Use cases

Pm2 NuXT Project Case Description 1. Start nuXT project

# xueerxingxi /xueerxingxi /xueerxingxi

Git pull CNPM I NPM run build

Pm2 start NPM –name “zoujuan” — run start

#pm2 list check whether the project is successfully started. #pm2 list check whether the project is successfully started. #pm2 list check whether the project is successfully started. pm2 list

# If there is a lot of web code, it indicates that the project is running successfully. Curl 127.0.0.1:4003

# xueerxingxi /xueerxingxi /xueerxingxi

Git pull CNPM I NPM run build

Pm2 restart Zoujuan

#pm2 list check whether the project is successfully started. #pm2 list check whether the project is successfully started. #pm2 list check whether the project is successfully started. Pm2 list 3. Use a script to perform updates

The code is updated and dependencies are installed and packaged with each update, followed by a reboot, so using the SH script to update is the most convenient. 1. Script class capacity

Keyword = 1echo−e”\n============= “Echo – e” \ n = = = = = = = = = = = = = directly in the online directory packaging cause problems of online short visit “echo – e” \ n = = = = = = = = = = = = = company project proposal in other directories or test environment after packaging, Then execute the update script and copy the packaged files to the online “echo−e”\n============= “echo− E “\n============= “echo− E “\n============= “echo− E “\n============= “echo− E “\n============= \n”read−p”============= Whether to package the update code? [y/n]?” IsPullif [[1 echo -e “\n============= “Echo – e” \ n = = = = = = = = = = = = = directly in the online directory packaging cause problems of online short visit “echo – e” \ n = = = = = = = = = = = = = company project proposal in other directories or test environment after packaging, Then execute the update script and copy the packaged files to the online “echo-e “\n=============. This is not a project with a large number of visits of the company, so there is no experience problem, so directly package the directory online. \ n “read – p” = = = = = = = = = = = = = update package code? [y/n]? “isPull if echo [[1 – e” \ n = = = = = = = = = = = = = note: “Echo – e” \ n = = = = = = = = = = = = = directly in the online directory packaging cause problems of online short visit “echo – e” \ n = = = = = = = = = = = = = company project proposal in other directories or test environment after packaging, Then execute the update script and copy the packaged files to the online “echo−e”\n============= “echo− E “\n============= “echo− E “\n============= “echo− E “\n============= “echo− E “\n============= \ n “read – p” = = = = = = = = = = = = = update package code? [y/n]? “isPullif [[isPull = = ‘y’]]; then

# packaged if [z $1) | | [[" vue "= ~ $keyword]]. Then the echo update xueerxingxi... CD /2021web/xueerxingxi git reset --hard git pull CNPM I echo -e '\n\n' echo CD /2021web/xueerxingxi NPM run build echo -e '\n\n' echo Echo -e '\n\n' echo Pm2 restart zoujuan fi # Echo -e '\n\n' echo Run the pm2 list command to check whether the project is restarted.Copy the code

fi

2. Use of scripts

# CD to script directory CD /2021web

Sh 01-zoujuan-xueerxingxi.sh -xuejuan -xueerxingxi.sh -xuejuan -xueerxingxi.sh