hyj1991 / easy-monitor

企业级 Node.js 应用性能监控与线上故障定位解决方案

Home Page:http://www.devtoolx.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

部署在linux后,访问项目出现这个,查看MeM

qyjandroid opened this issue · comments

[Easy-Monitor: dashboard <8090>] tcpserver->error Error: read ECONNRESET

image
卡在这里了,没有错误提示

你是怎么启动的

一直显示开始进行memory数据采集

pm2启动项目的

怎么部署的

你是怎么启动的

pm2 启动项目的

怎么部署的
在linux上部署
1:npm install easy-monitor
2:nodejs 入口文件添加:const easyMonitor = require('easy-monitor')
easyMonitor('test9')
3:bulid ts为js,然后通过pm2 start 启动app.js

4:由于服务器没有对外开放12333,所以通过nginx转发7001端口到12333上,在windows上就可以访问了

怎么部署的
在linux上部署
1:npm install easy-monitor
2:nodejs 入口文件添加:const easyMonitor = require('easy-monitor')
easyMonitor('test9')
3:bulid ts为js,然后通过pm2 start 启动app.js

4:由于服务器没有对外开放12333,所以通过nginx转发7001端口到12333上,在windows上就可以访问了

{
"apps": [
{
"error_file": "err.log",
"log_date_format": "YYYY-MM-DD HH:mm:ss.SSS Z",
"name": "app_ws_4000",
"port": 4000,
"script": "./dist/app.js",
"env": {
"NODE_ENV": "devIn",
},
"env_out": {
"NODE_ENV": "devOut",
}
}
]
}

linux 上启动后,本地 curl 127.0.0.1:12333 看看有没有响应呢

linux 上启动后,本地 curl 127.0.0.1:12333 看看有没有响应呢

有的,界面可以正常访问,os可以正常,但是MEM点击开始以后,一直提示收集数据中。

下面是PM2启动以后,easy-monitor日志。
19|app_ws_ | 2019-12-10 17:45:28.359 +08:00: 当前环境 devIn
19|app_ws_ | 2019-12-10 17:45:28.382 +08:00: 监听端口 4000
19|app_ws_ | 2019-12-10 17:45:28.402 +08:00: [Easy-Monitor: embrace <13517>] connect to 127.0.0.1:26666 success...
19|app_ws_ | 2019-12-10 17:45:28.756 +08:00: [Easy-Monitor: dashboard <13541>] http server has been started, this [13541] will be closed...
19|app_ws_ | 2019-12-10 17:45:28.760 +08:00: [Easy-Monitor] child_process [13541] exit with code 0...
19|app_ws_ | 2019-12-10 17:50:47.793 +08:00: 当前环境 devIn
19|app_ws_ | 2019-12-10 17:50:47.817 +08:00: 监听端口 4000
19|app_ws_ | 2019-12-10 17:50:47.837 +08:00: [Easy-Monitor: embrace <13712>] connect to 127.0.0.1:26666 success...
19|app_ws_ | 2019-12-10 17:50:48.193 +08:00: [Easy-Monitor: dashboard <13734>] http server has been started, this [13734] will be closed...
19|app_ws_ | 2019-12-10 17:50:48.198 +08:00: [Easy-Monitor] child_process [13734] exit with code 0...
19|app_ws_ | 2019-12-10 17:56:02.290 +08:00: 当前环境 devIn
19|app_ws_ | 2019-12-10 17:56:02.314 +08:00: 监听端口 4000
19|app_ws_ | 2019-12-10 17:56:02.334 +08:00: [Easy-Monitor: embrace <14268>] connect to 127.0.0.1:26666 success...
19|app_ws_ | 2019-12-10 17:56:02.684 +08:00: [Easy-Monitor: dashboard <14280>] http server has been started, this [14280] will be closed...
19|app_ws_ | 2019-12-10 17:56:02.688 +08:00: [Easy-Monitor] child_process [14280] exit with code 0...

你是不是安装 v8-profiler-node8 这个包没有成功

linux 上我没有安装这个包

easy-monitor 要依赖这个包的啊,你把 node_modules 删掉,重新安装下 easy-monitor 看看

好的,我试了下,应该直接就安装成功了!
image

好的,我试了下,应该直接就安装成功了!
image

os,cpu都正常,只有MEM进去以后一直是数据采集中。

试下 http://47.100.164.242/document/#/?id=-%e8%99%9a%e6%8b%9f%e8%b7%af%e5%be%84%e8%bd%ac%e5%8f%91 这个虚拟路径转发的方式部署呢?

直接 nginx 转发没试过

试下 http://47.100.164.242/document/#/?id=-%e8%99%9a%e6%8b%9f%e8%b7%af%e5%be%84%e8%bd%ac%e5%8f%91 这个虚拟路径转发的方式部署呢?

直接 nginx 转发没试过
下面是nginx设置
image
下面是编译完的app.js文件中引用
image
image
下面是nginx日志
image

你用配置的 sever name + 7001 端口访问了么

你用配置的 sever name + 7001 端口访问了么

是的,可以看到有nginx日志,但是去找monitor目录的时候找不到

404 显然都没走到你配置的 nginx 规则这里。/monitor 这个路由是配置在 nginx 上的,这里看起来是你的 nginx 配置有问题

404 显然都没走到你配置的 nginx 规则这里。/monitor 这个路由是配置在 nginx 上的,这里看起来是你的 nginx 配置有问题

下面是我在代码中引入,加入前缀

image
我看到日志输出,加入的代码是最新的了。
image

重点:但是当我直接curl 127.0.0.1:12333,看到prefix并没有添加上去。

image

这确实挺奇怪的,我在机器上部署了一个测试 demo 是可以看到 http prefix 生效的:

image

这确实挺奇怪的,我在机器上部署了一个测试 demo 是可以看到 http prefix 生效的:

image

是否nginx有缓存,或者http server 有缓存需要重启呢

这确实挺奇怪的,我在机器上部署了一个测试 demo 是可以看到 http prefix 生效的:
image

是否nginx有缓存,或者http server 有缓存需要重启呢
我想了想觉得这个跟虚拟路径转发没有根本的关系,我又改回原来的方式,os,cpu可以正常访问,MEM不能正常访问。我查看了下网络请求,如下:
os下,数据正常返回。
image
MEM下,数据一直为空。
image

数据获取不到是什么原因导致的呢?

按照 http://47.100.164.242/document/#/?id=-%e6%97%a5%e5%bf%97%e7%ba%a7%e5%88%ab 这里把日志级别改为 debug,然后你再访问下,把服务端的 debug 日志贴出来看下

按照 http://47.100.164.242/document/#/?id=-%e6%97%a5%e5%bf%97%e7%ba%a7%e5%88%ab 这里把日志级别改为 debug,然后你再访问下,把服务端的 debug 日志贴出来看下

非常感谢您的帮助,我找到问题了,原因是我node项目中引用了log4js,log4js应该有进程通讯,我把log4js先关掉以后,重新启动就正常了!
image

好的,搞定了就好,我先关闭 issue 了