@arextest/arex-node-runner

0.0.3-beta.16.7 • Public • Published

背景

arex node-agent 中间件启动器

环境

  1. node v18
  2. npm --registry https://registry.npmjs.org
  3. arex-node-agent
  4. arextest https://github.com/arextest/arex

内容

  1. 包含通过APPID装载平台配置的中间件,自定义js装载等
  2. 包含初始化agent逻辑
  3. 包含按照APP配置初始化agent 执行频次,启停等

运行方案

  • 安装启动runner npm install @arextest/arex-node-runner -g --registry https://registry.npmjs.org

  • trip npm install @arextest/arex-node-runner@1.0.3-beta.15 --registry http://registry.npm.release.ctripcorp.com

  • 配置环境变量 export AREX_HOST=http://xxx:8093 export APPID=demo01 export INSTRUMENTATIONS=ArexHttpInstrumentation,ArexHttpClientInstrumentation

  • 修改export 让require支持远程npm包 export NODE_PATH=$(npm root -g)

  • 配置启动命令 node --require @arextest/arex-node-runner dist/main.js

  • PM2 方案

    • 支持pm2 fork 模式
      配置参数:--node-args="--require @arextest/arex-node-runner"
    • 支持pm2 cluster多实例模式 配置参数: --interpreter="node" \ --interpreter-args='--require @arextest/arex-node-runner' 案例: `pm2 start ./dist/src/main.js
      --name $appname
      -i 4
      --merge-logs
      --log-date-format="YYYY-MM-DD HH:mm:ss"
      --log /opt/logs/$appid/outerr.log
      --output /opt/logs/$appid/out.log
      --error /opt/logs/$appid/err.log
      --interpreter="node"
      --interpreter-args='--require @arextest/arex-node-runner'

    --node-args="--require @arextest/arex-node-runner" \

exit 0`

通过js参数传递:-- --APPID N$appname --AREX_HOST http://xxx --INSTRUMENTATIONS ArexHttpInstrumentation,ArexHttpClientInstrumentation,ArexMysql2Instrumentation

` NODE_ENV=production pm2 start dist/main.js
-i $instance
--name $appname
--merge-logs
--log-date-format "YYYY-MM-DD HH:mm:ss.SSS"
--log "/opt/logs/$appid/outerr.log"
--output "/opt/logs/$appid/out.log"
--error "/opt/logs/$appid/err.log"
--interpreter-args='--require /opt/nodeapp/node_modules/@arextest/arex-node-runner/dist/index.js'
-- --APPID N$appname --AREX_HOST http://xxx --INSTRUMENTATIONS ArexHttpInstrumentation,ArexHttpClientInstrumentation,ArexMysql2Instrumentation

exit 0 `

参考

  1. npm 发布流程
  • 申请权限
  • npm login --registry https://registry.npmjs.org
  • npm publish --registry https://registry.npmjs.org --access=public

Readme

Keywords

none

Package Sidebar

Install

npm i @arextest/arex-node-runner

Weekly Downloads

0

Version

0.0.3-beta.16.7

License

ISC

Unpacked Size

9.78 MB

Total Files

3

Last publish

Collaborators

  • onepone
  • zhangtao25
  • jingum
  • fly-1999