Node.js/pm2:修订间差异

来自康健生活
Kangkk​(留言 | 贡献)
创建页面,内容为“== 引言 == == 守护进程 == <blockquote> <syntaxhighlight lang="bash"> pm2 start ./bin/www --watch </syntaxhighlight></blockquote> == 参数 == * --watch:监…”
 
Kangkk​(留言 | 贡献)
 
(未显示同一用户的5个中间版本)
第22行: 第22行:
| 停止 || pm2 list<br>
| 停止 || pm2 list<br>
pm2 stop app_name|app_id<br>
pm2 stop app_name|app_id<br>
pm2 stop all|| 示例
pm2 stop all
| 示例
|-
|-
| 删除 || pm2 start app.js || 示例
| 删除 || pm2 start app.js || 示例
|-
|-
| 查看 ||  pm2 describe 0 || 示例
| 查看 ||  pm2 describe 0 || 示例
|-
| 查看进程 ||  pm2 show 0<br> pm2 info 0|| 0为PM2进程id
|-
|-
| 日志 ||  pm2 logs || 示例
| 日志 ||  pm2 logs || 示例
第35行: 第38行:
|-
|-
| 开机自启动 ||  pm2 save<br>
| 开机自启动 ||  pm2 save<br>
pm2 startup [platform]|| 示例
pm2 startup [platform]
| 示例
|-
|-
| node args ||  pm2 start app.js --node-args="--harmony" || 示例
| node args ||  pm2 start app.js --node-args="--harmony" || 示例
第43行: 第47行:
| 自动重启 ||  pm2 start big-array.js --max-memory-restart 20M || 示例
| 自动重启 ||  pm2 start big-array.js --max-memory-restart 20M || 示例
|}
|}
== 配置文件 ==
== 配置文件 ==
== 技巧 ==
使用 <code>npm start</code> 启动并为进程命名。
{{shc|<syntaxhighlight lang="bash">
pm2 start npm --name newname -- start</syntaxhighlight>|$|/home/kangkk}}
运行一个自定义的脚本
{{shc|<syntaxhighlight lang="bash">
pm2 start npm -- run custom
</syntaxhighlight>|$|/home/kangkk}}
== 内存 ==
=== 最大内存 ===
超过最大内存限制会自动崩溃,并且在项目目录下生成 core.pid 文件。
{{Shc_out|<syntaxhighlight lang="bash">
ls</syntaxhighlight>|<syntaxhighlight lang="bash">access.log        core.12829        core.18594        core.25013        core.30818        core.3395          core.38790        core.7218          node_modules
core.10177        core.12879        core.19192        core.25899        core.3145          core.33993        core.3940          core.73            package-lock.json
core.10761        core.13908        core.19809        core.26633        core.31677        core.3411          core.40785        core.7915          package.json
core.10846        core.14130        core.20295        core.27303        core.32116        core.34497        core.4699          core.831          production.js
core.11179        core.1479          core.20761        core.2786          core.3262          core.34850        core.5085          core.8571          runtime
core.11552        core.15413        core.20875        core.29218        core.32642        core.36601        core.6035          core.9859          src
core.12064        core.17588        core.21868        core.29462        core.32854        core.36950        core.6157          error.log          view
core.12648        core.17661        core.23078        core.30426        core.33591        core.37015        core.6284          nginxStarter.sh
</syntaxhighlight>|$|/home/kangkk}}
==== file ====
使用 file。
{{Shc_out|<syntaxhighlight lang="bash">
file core.38790</syntaxhighlight>|<syntaxhighlight lang="bash">
core.38790: ELF 64-bit LSB core file, x86-64, version 1 (SYSV), too many program headers (3594)
</syntaxhighlight>|$|/home/kangkk}}
== vue ==
== vue ==
<blockquote>
<blockquote>