安装
npm install -g pm2
常用命令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| pm2 list
pm2 start app.js pm2 restart app_name/id pm2 stop app_name/id pm2 delete app_name/id
pm2 log pm2 info pm2 monit
pm2 start app.js -i 4 pm2 start app.js pm2 list pm2 monit pm2 logs pm2 stop all pm2 restart all pm2 reload all pm2 stop 0 pm2 restart 0 pm2 startup pm2 web pm2 delete 0 pm2 delete all
|
运行进程的不同方式
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| -i
-n -o -e
pm2 start app.js -i max pm2 start app.js -i 3 pm2 start app.js -x pm2 start app.js -x pm2 start app.js pm2 stop serverone pm2 start app.json pm2 start app.js -i max pm2 start app.js -i max -e err.log -o out.log
|
简单配置
启动 pm2 start pm2.conf.json
pm2.conf.json
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| { "apps": [{ "name" : "fis-receiver", "script" : "./bin/www", "cwd" : "./", "watch": [ "bin", "routers" ], "ignore_watch" : [ "node_modules", "logs", "public" ], "watch": true, "instances": 4, "error_file" : "./logs/app-err.log", "out_file" : "./logs/app-out.log", "log_date_format": "YYYY-MM-DD HH:mm:ss", "env": { "NODE_ENV": "production" } }] }
|
如有问题可联系 Email:afacode@outlook.com 或 微信:afacode