FFFF 使用 vscode@1.6 断点调试 egg cluster · Issue #15 · atian25/blog · GitHub
[go: up one dir, main page]

Skip to content

使用 vscode@1.6 断点调试 egg cluster #15

Closed

Description

@atian25

前言

上一次的折腾参见: #14

配置

在刚发布的 vscode 1.6 release note 中, 可以解决该问题, 具体步骤:

    在项目中按 F5 生成 .vscode/launch.json (如果之前有, 先删除)
  • 修改生成的文件的 configurations[0] 节点, 增加以下信息
  "runtimeArgs": [
     "--nolazy", "--debug"
  ],
  "port": 5859,

image

  • 再次 F5 重启

遗留问题

  • 在 egg-development 自动重启后, 还不能自动重连
  • 但从上一次折腾中的收获, 应该是可以写个插件搞定这个事
  • 先研究下.

Activity

  1. atian25 commented on Oct 11, 2016

    @atian25
    OwnerAuthor

    好像有问题, 重启后端口占用, 之前的进程没退出.
    估计是 egg cluster 守护了, vscode 干不掉, 再研究下

    研究结果:

    update:

    • 目前的 vscode 对多进程的 debug 支持不好, 要等下个版本.
    • 个人建议是在外面 npm run dev -- --debug 然后 vscode 里面 attach.
    • 或者直接 npm run dev -- --inspect 用 chrome 来 debug
  2. atian25 commented on Dec 21, 2016

    @atian25
    OwnerAuthor

    1.8 里面可以这么用, 虽然调试体验还是一般.

    {
      "version": "0.2.0",
      "configurations": [
        {
          "name": "start egg",
          "type": "node",
          "request": "launch",
          "program": "${workspaceRoot}/index.js",
          "cwd": "${workspaceRoot}",
          "runtimeArgs": [
            "--debug"
          ],
          "port": 5859
        },
        {
          "name": "attach worker",
          "type": "node",
          "request": "attach",
          "port": 5858
        },
        {
          "name": "attach agent",
          "type": "node",
          "request": "attach",
          "port": 5856
        }
      ],
      "compounds": [
        {
          "name": "egg debug",
          "configurations": ["start egg", "attach worker", "attach agent"]
        }
      ]
    }
  3. atian25 commented on Jan 3, 2017

    @atian25
    OwnerAuthor

    嗯, 因为 attach 的太晚了, 这个可以再研究下.

    我目前是放弃用 vscode 来 debug, 直接用 webstorm

  4. atian25 commented on Jan 4, 2017

    @atian25
    OwnerAuthor

    如图, 无需什么特别配置
    webstorm-debug

  5. atian25 commented on Feb 4, 2017

    @atian25
    OwnerAuthor

    https://code.visualstudio.com/updates/v1_9#_debugging

    1.9 版做了些优化,Nodemon Setup 和 'restart' option,有兴趣的同学可以研究下,如何主动 attach 新的 worker debug port

  6. atian25 commented on Feb 27, 2017

    @atian25
    OwnerAuthor

    更新下,可以直接用 webstorm debug npm scripts 了,无需写入口文件。

    修改 npm scripts 为:

    {
      "dev": "egg-bin dev -- $NODE_DEBUG_OPTION",
    }

    然后在 webstorm 里面配置一个 npm 的 configuration 即可

    image

    用 webstorm debug 启动后,环境变量 $NODE_DEBUG_OPTION 被赋值为类似 --debug-brk=53243 --expose_debug_as=v8debug,从而被 egg-bin 传递进去。

  7. atian25 commented on Mar 21, 2017

    @atian25
    OwnerAuthor

    egg-bin 已经重构,支持传参,最新的 3.0,要去掉 --,即:

    并且 debug 指令改为继承 dev, 故建议用 egg-bin debug

    {
       "scripts": {
          "dev": "egg-bin debug $NODE_DEBUG_OPTION",
      }
    }
    

    https://github.com/eggjs/egg-bin#command

  8. atian25 commented on Mar 27, 2017

    @atian25
    OwnerAuthor

    我擦,vscode 的 debug,支持 The Restart Frame action allows you to re-enter the current function after you have changed variables with the Set Value action

    新文档不错
    https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_restart-frame-node

  9. boizz commented on Mar 27, 2017

    @boizz

    webstorm启动一些大型例如node_modules里面的文件夹层级太多的项目很容易崩

  10. atian25 commented on Mar 27, 2017

    @atian25
    OwnerAuthor
  11. boizz commented on Mar 27, 2017

    @boizz
  12. atian25 commented on Apr 21, 2017

    @atian25
    OwnerAuthor

    现在通过 @okoala 写的 egg-development-proxyworker 可以完美实现 vscode debug egg 了。详见:https://eggjs.org/zh-cn/core/development.html#使用-vscode-进行调试

  13. 8 remaining items

  14. atian25 commented on Jun 13, 2017

    @atian25
    OwnerAuthor
  15. okoala commented on Jun 13, 2017

    @okoala

    那个覆盖率问题,我稍后完善,不影响使用~

  16. huboshu0819 commented on Jun 13, 2017

    @huboshu0819

    @okoala 刚去官网提了issue,我看配置文件里面我有设置启动 attach worker额。
    image

  17. okoala commented on Jun 13, 2017

    @okoala

    @huboshu0819 直接在官网交流吧~

  18. okoala commented on Jun 13, 2017

    @okoala
  19. atian25 commented on Sep 14, 2017

    @atian25
    OwnerAuthor

    终于可以宣布该问题完美解决了~

  20. ChaofengYan commented on Sep 20, 2017

    @ChaofengYan

    image

    之前还好使的,现在一直报错

  21. atian25 commented on Sep 20, 2017

    @atian25
    OwnerAuthor

    @ChaofengYan npm update 了没? 删除依赖重新安装下,不要 lock。

  22. ChaofengYan commented on Sep 20, 2017

    @ChaofengYan

    @atian25 使用egg-init 新建的一个type=simple项目,使用npm i安装依赖,没有lock,依然报同样的错误

  23. atian25 commented on Sep 20, 2017

    @atian25
    OwnerAuthor

    我试了本地无法复现。

  24. changed the title [-]使用 vscode@1.6 断点调试 egg cluster[/-] [+]使用 vscode 断点调试 egg[/+] on Feb 8, 2018
  25. changed the title [-]使用 vscode 断点调试 egg[/-] [+]使用 vscode@1.6 断点调试 egg cluster[/+] on Feb 8, 2018
  26. atian25 commented on Feb 8, 2018

    @atian25
    OwnerAuthor

    终于,今天 VSCode@1.12.0 正式支持了 Automatically attach debugger to Node.js subprocesses

    我们这个问题可以完美解决了,详细描述参见:#25

  27. boizz commented on Feb 9, 2018

    @boizz

    天猪威武

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0