Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

egg 使用心得收集 #254

Closed
atian25 opened this issue Jan 13, 2017 · 12 comments
Closed

egg 使用心得收集 #254

atian25 opened this issue Jan 13, 2017 · 12 comments

Comments

@atian25
Copy link
Member

atian25 commented Jan 13, 2017

鉴于 egg 文档基本上完成第一稿了,现向各位征集 egg 使用和实践心得之类的文章。

请在本 issue 回复对应的 blog 文章地址。

参考格式:

- [ ] [使用 [email protected] 断点调试 egg cluster](https://github.com/atian25/blog/issues/15) by @atian25
@popomore
Copy link
Member

侧栏增加「资源」resources

@atian25
Copy link
Member Author

atian25 commented Jan 13, 2017

@popomore 在此收集,然后合适的文章我们再收录到官网文档。

@garygchai
Copy link

garygchai commented Jan 13, 2017

学习egg的时候发现它的调试挺蛋疼,自己研究了一下写了个教程,分享一下:
egg debug教程

@popomore
Copy link
Member

@garygchai 有个内网链接

@popomore
Copy link
Member

popomore commented Feb 15, 2017

放到这里 https://eggjs.org/zh-cn/resource.html

@myfreax
Copy link
Contributor

myfreax commented Feb 23, 2017

@garygchai 你的文章应该修改一下

master 负责启动其他进程的叫做 master 进程,基本不干活,只负责启动 agent 和 worker 和其他一些简单的工作; 
  startMasterSocketServer(cb) {
    // Create the outside facing server listening on our port.
    require('net').createServer({ pauseOnConnect: true }, connection => {
      // We received a connection and need to pass it to the appropriate
      // worker. Get the worker for this connection's source IP and pass
      // it the connection.
      const worker = this.stickyWorker(connection.remoteAddress);
      worker.send('sticky-session:connection', connection);
    }).listen(this.options.port, cb);
  }

@atian25
Copy link
Member Author

atian25 commented Feb 23, 2017

这个是 @ngot 新加的, 为 socket.io 做的铺垫

@junmaqiang
Copy link

注册,登录, 权限管理, 等需要一些demo

@xinayida
Copy link

xinayida commented Aug 26, 2017

使用VSCode调试时发现一直报超时错误,看了一下调试控制台发现是端口有问题

npm run debug 
Debugger listening on ws://127.0.0.1:9229/1929f429-9768-47cd-bf78-1df5b40ed25f
Debugger listening on ws://127.0.0.1:5856/841f67a3-3c94-4239-b918-a897613de816
Debugger listening on ws://127.0.0.1:9230/36a18162-9f81-43ea-b583-f24e88a8783d

将Launch Egg任务的端口号改成9229后可以正常调试,不知道是不是我的环境问题

   "configurations": [
        {
            "name": "Launch Egg",
            "type": "node",
            "request": "launch",
            "cwd": "${workspaceRoot}",
            "runtimeExecutable": "npm",
            "windows": {
              "runtimeExecutable": "npm.cmd"
            },
            "runtimeArgs": [
              "run", "debug"
            ],
            "protocol": "inspector",
            "port": 9229 //由5858改为9229
        },
        ...

VSCode:1.15.1
node:v8.2.1

  "dependencies": {
    "egg": "^1.7.0",
    "egg-development-proxyworker": "^1.1.1",
  },
  "devDependencies": {
    "egg-bin": "^4.1.0",
  }

@duanjun
Copy link

duanjun commented Sep 7, 2017

@xinayida 这个问题折腾了一天多,前后看了不少的源代码,走了些弯路,调试终于是比较爽了,node8之后调试,agent默认调试端口是5856, 除了你提到的9229端口修改之外,还要改下 agent协议也改成inspector

同时如果是--inspector-brk 调试, vscode attact 默认超时时间是10s钟,很容易过,所以后面框架启动代码是很难断得到,所以还要把timeout时间延长到比你启动框架时间长

分享下我的调试文件,现在完美调试,希望调试egg的同学不在困扰了,希望官方文档也更新下,新手容易迷失

ps: vscode 1.15.1
os: mac osx
node: 8.1
我用了egg-development-proxyworker 确实很爽!

"configurations": [
      {
          "type": "node",
          "request": "attach",
          "timeout": 600000,
          "name": "Attach Worker",
          "protocol": "inspector",
          "restart": true,
          "port": 10086 
      },
      {
          "name": "Launch Egg",
          "type": "node",
          "request": "launch",
          "cwd": "${workspaceRoot}",
          "runtimeExecutable": "npm",
          "windows": {
              "runtimeExecutable": "npm.cmd"
          },
          "runtimeArgs": [
              "run",
              "debug",
          ],
          "protocol": "inspector",
          "port": 9229
      },
      {
          "name": "Attach Agent",
          "timeout": 600000,
          "type": "node",
          "request": "attach",
          "protocol": "inspector",
          "port": 5856 
      }
  ]

@atian25
Copy link
Member Author

atian25 commented Sep 7, 2017

调试的优化看 #1376
等下周回来搞完最后两个,会比现在的体验好很多。

@atian25
Copy link
Member Author

atian25 commented Oct 18, 2017

@atian25 atian25 closed this as completed Oct 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants