关于前端:pm2-常用命令

5次阅读

共计 952 个字符,预计需要花费 3 分钟才能阅读完成。

$ npm install pm2 -g     # 命令行装置 pm2 
$ pm2 start app.js -i 4 #后盾运行 pm2,启动 4 个 app.js,模仿启动 4 个 app.js 的利用实例 # 4 个应用程序会主动进行负载平衡
                                # 也能够把 'max' 参数传递给 start
                                # 正确的过程数目依赖于 Cpu 的外围数目
$ pm2 start app.js --name my-api # 命名过程
$ pm2 list               # 显示所有过程状态
$ pm2 monit              # 监督所有过程
$ pm2 logs               #  显示所有过程日志
$ pm2 stop all           # 进行所有过程
$ pm2 restart all        # 重启所有过程
$ pm2 reload all         # 0 秒停机重载过程 (用于 NETWORKED 过程)
$ pm2 stop 0             # 进行指定的过程
$ pm2 restart 0          # 重启指定的过程
$ pm2 startup            # 产生 init 脚本 放弃过程活着
$ pm2 web                # 运行强壮的 computer API endpoint (http://localhost:9615)
$ pm2 delete 0           # 杀死指定的过程
$ pm2 delete all         # 杀死全副过程

运行过程的不同形式:$ pm2 start app.js -i max  # 依据无效 CPU 数目启动最大过程数目
$ pm2 start app.js -i 3      # 启动 3 个过程
$ pm2 start app.js -x        #用 fork 模式启动 app.js 而不是应用 cluster
$ pm2 start app.js -x -- -a 23   # 用 fork 模式启动 app.js 并且传递参数 (-a 23)
$ pm2 start app.js --name serverone  # 启动一个过程并把它命名为 serverone
$ pm2 stop serverone       # 进行 serverone 过程
$ pm2 start app.json        # 启动过程, 在 app.json 里设置选项
$ pm2 start app.js -i max -- -a 23                   #在 -- 之后给 app.js 传递参数
$ pm2 start app.js -i max -e err.log -o out.log  # 启动 并 生成一个配置文件
你也能够执行用其余语言编写的 app  (fork 模式):
$ pm2 start my-bash-script.sh    -x --interpreter bash
$ pm2 start my-python-script.py -x --interpreter python
正文完
 0