From ddbb4b3c0ec7cfc5c9b1baa7e678770613bd4761 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?TZ=20=7C=20=E5=A4=A9=E7=8C=AA?= Date: Fri, 26 Jan 2018 11:13:04 +0800 Subject: [PATCH] docs(deploy): add alinode (#2025) --- docs/source/zh-cn/core/deployment.md | 77 ++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/docs/source/zh-cn/core/deployment.md b/docs/source/zh-cn/core/deployment.md index 1925a0f96d..4d455f8ea7 100644 --- a/docs/source/zh-cn/core/deployment.md +++ b/docs/source/zh-cn/core/deployment.md @@ -103,7 +103,84 @@ $ egg-scripts stop [--title=egg-server] 你也可以直接通过 `ps -eo "pid,command" | grep "--type=egg-server"` 来找到 master 进程,并 `kill` 掉,无需 `kill -9`。 +## 监控 + +我们还需要对服务进行性能监控,内存泄露分析,故障排除等。 + +业界常用的有: +- [Node.js 性能平台(alinode)](https://www.aliyun.com/product/nodejs) +- [NSolid](https://nodesource.com/products/nsolid/) + +### Node.js 性能平台(alinode) + +[Node.js 性能平台](https://www.aliyun.com/product/nodejs) 是面向所有 Node.js 应用提供 性能监控、安全提醒、故障排查、性能优化 等服务的整体性解决方案,凭借对 Node.js 内核深入的理解,提供完善的工具链和服务,协助客户主动、快速发现和定位线上问题。 + +#### 安装 runtime + +全局安装方式参见[文档](https://help.aliyun.com/document_detail/60338.html)。 + +有时候,同机会部署多个项目,期望多版本共存时,则可以把 runtime 安装到当前项目: + +```bash +$ npm i nodeinstall -g +$ nodeinstall --install-alinode ^3 +``` + +[nodeinstall] 会把对应版本的 `alinode` 安装到项目的 `node_modules` 目录下。 + +注意:打包机的操作系统和线上系统需保持一致,否则对应的 runtime 不一定能正常运行。 + +#### 安装及配置 + +我们提供了 [egg-alinode] 来快速接入,无需安装 `agenthub` 等额外的常驻服务。 + +**安装依赖:** + +```bash +$ npm i egg-alinode --save +``` + +**开启插件:** + +```js +// config/plugin.js +exports.alinode = { + enable: true, + package: 'egg-alinode', +}; +``` + +**配置:** + +```js +// config/config.default.js +config.alinode = { + // 从 `Node.js 性能平台` 获取对应的接入参数 + appid: '', + secret: '', +}; +``` + +### 启动应用 + +`npm scripts` 配置的 `start` 指令无需改变,通过 `egg-scripts` 即可。 + +启动命令需使用 `npm start`,因为 `npm scripts` 执行时会把 `node_module/.bin` 目录加入 `PATH`,故会优先使用当前项目执行的 Node 版本。 + +启动后会看到 master 日志包含以下内容: + +```bash +$ [master] node version v8.9.4 +$ [master] alinode version v3.8.4 +``` + +#### 访问控制台 + +控制台地址:https://node.console.aliyun.com + [egg-cluster]: https://github.com/eggjs/egg-cluster [egg-scripts]: https://github.com/eggjs/egg-scripts +[egg-alinode]: https://github.com/eggjs/egg-alinode [pm2]: https://github.com/Unitech/pm2 +[nodeinstall]: https://github.com/cnpm/nodeinstall \ No newline at end of file