1、執行命令
# npm install -g pm2
2、驗證是否安裝成功,執行命令
# pm2 -v
3、pm2使用
常用命令:
命令 | 說明 |
---|---|
pm2 startup | 設置pm2開機自啟動 |
pm2 unstartup | 移除pm2開機自啟動 |
pm2 save | 保存當前進程開機自啟動 |
pm2 start <進程啟動命令> [--name <進程名>] | 啟動應用程序 |
pm2 list | 顯示所有進程狀態 |
pm2 monit | 監控進程 |
pm2 logs [進程id或名字] | 顯示進程日志 |
pm2 stop [all] | 停止[所有]進程 |
pm2 restart [all] | 重啟[所有]進程 |
pm2 delete [<進程名或者id>,all] | 刪除指定[所有]進程 |
pm2 info [進程id或名字] | 查看應用程序信息 |
4、使用 pm2 守護 ASP.NET Core 應用程序
找到項目dll位置,執行命令: # pm2 start "dotnet testwebapi.dll" --name testwebapi 檢查是否成功: # curl http://localhost:5000 查看日志: # pm2 logs testwebapi 查看應用程序信息: # pm2 info testwebapi
4、使用 pm2 守護 node項目 應用程序
// 啟動node web項目
pm2 start "node ./app.js" --name adminVue
停止進程:
// 1 是id pm2 stop 1
刪除進程:
// 1是ID pm2 delete 1
重啟進程:
// 1是ID pm2 restart 1