Skip to content
This repository has been archived by the owner on Jun 17, 2021. It is now read-only.

egg,egg-core模块无法追踪 #146

Open
ugvgylkm opened this issue Mar 23, 2021 · 1 comment
Open

egg,egg-core模块无法追踪 #146

ugvgylkm opened this issue Mar 23, 2021 · 1 comment

Comments

@ugvgylkm
Copy link

ugvgylkm commented Mar 23, 2021

安装完如下模块后https://www.npmjs.com/package/skyapm-nodejs 版本 _skyapm-nodejs@2.0.1@skyapm-nodejs
在执行文件require-module-hook.js里代码时如果是egg模块无法进入如下图回调函数(requireCallback),如果是http模块正常走requireCallback方法

image

@ugvgylkm
Copy link
Author

ugvgylkm commented Mar 25, 2021

2种方式

  1. 在package.json里用egg-scripts start 启动, 文档里启动方式
"scripts": {
    "start": "egg-scripts start --workers=1 --require skyapm-egg-require --sw_service_name=test --sw_direct_Servers=127.0.0.1:8888",
}

2.用startCluster启动方式

// 配置环境变量
const testPathReg = /\/test/;
const pathReg = /\/prod/;
const simPathReg = /\/sim/;
if (testPathReg.test(__dirname)) {
    process.env.EGG_SERVER_ENV = 'unittest';  //测试环境
} else if (pathReg.test(__dirname)) {
    process.env.EGG_SERVER_ENV = 'prod'; //正式环境
} else if (simPathReg.test(__dirname)) {
    process.env.EGG_SERVER_ENV = 'sim';  //仿真环境
} else {
    process.env.EGG_SERVER_ENV = 'local'; //本地环境
    //如下是探针配置
    process.env.SW_SERVICE_NAME = testservicename';
    process.env.SW_INSTANCE_NAME = 'testinstancename' ;
    process.env.SW_DIRECT_SERVERS = '127.0.0.1:8888';
    process.env.SW_AUTHENTICATION = '';
}
egg.startCluster({
    workers: 1,
    baseDir: __dirname,
    require: ['skyapm-egg-require'], // egg探针模块
});

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant