maomingchao

centos 下使用vscode 调试egg.js 注意事项

这两天在centos下,直接用vscode运行egg.js的例子。遇到个问题就是当安装了vscode-egg插件,会遇到一个现象。就是同样的代码,Windows下调试可以顺利进行,但是centos有时候好,有时候不行,因为也是刚刚在做这一块工作,知其然,不知其所以然。

在egg.js下发了帖子。明白了道理

https://github.com/eggjs/egg/issues/3283

根本原因就是参数配置区别;

其中,--inspect-brk 是指在进程第一行就暂停,等待 attach,因此:

  • master 先启动,在第一行会停住,需要你 attach master,才会往下走
  • 接着 master 启动 agent,也是在第一行停住,需要 attach agent 才会往下走
  • 最后 agent 启动完成后,worker 才开始启动,一样也是在第一行停住,需要 attach agent 才会往下走

配置我这里发一下

1.会出现停住的配置:

{
            "type": "node",
            "request": "launch",
            "name": "Egg Debug",
            "runtimeExecutable": "npm",
            "runtimeArgs": [
                "run",
                "debug",
                "--",
                "--inspect-brk"
            ],
            "console": "integratedTerminal",
            "restart": true,
            "protocol": "auto",
            "port": 9229,
            "autoAttachChildProcesses": true
        },

 

2.修改后的配置

{
            "type": "node",
            "request": "launch",
            "name": "Egg Debug",
            "runtimeExecutable": "npm",
            "runtimeArgs": [
                "run",
                "debug",
                "--",
                "--inspect"
            ],
            "console": "integratedTerminal",
            "restart": true,
            "protocol": "auto",
            "port": 9229,
            "autoAttachChildProcesses": true
        },

  

 

posted on 2018-12-09 16:23  maomingchao  阅读(836)  评论(0编辑  收藏  举报

导航