Code Monkey home page Code Monkey logo

egg-development-proxyworker's Introduction

egg-development-proxyworker

NPM version build status Test coverage David deps Known Vulnerabilities npm download

A proxy worker for debugging worker on egg

DEPRECATED, use egg-bin debug instead.

As in development stage, when we modify the code and save, the application will automatically restart the worker. But every time the worker's updates make the debug port change, And VSCode is required to attach to a fixed debug port. So we enabled a proxy service called proxyworker. Worker debugging information will be proxied to this service. And then VSCode through the fixed attach to proxyworker to debug the worker

The following are the installation steps:

1. Install egg-development-proxyworker plugin
npm i egg-development-proxyworker --save
2. Enable the plugin
// config/plugin.js
exports.proxyworker = {
  enable: true,
  package: 'egg-development-proxyworker',
};

// config/config.default.js
// If 10086 is occupied, you can specify the other port number through this configuration
exports.proxyworker = {
  port: 10086,
};
3. Add debug configuration in .vscode/launch.json :
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Launch Egg",
      "type": "node",
      "request": "launch",
      "cwd": "${workspaceRoot}",
      "runtimeExecutable": "npm",
      "windows": {
        "runtimeExecutable": "npm.cmd"
      },
      "runtimeArgs": [
        "run", "dev", "--", "--debug"
      ],
      "port": 5858
    },
    {
      "name": "Attach Agent",
      "type": "node",
      "request": "attach",
      "port": 5856
    },
    {
      "name": "Attach Worker",
      "type": "node",
      "request": "attach",
      "restart": true,
      "port": 10086
    }
  ],
  "compounds": [
    {
      "name": "Debug Egg",
      "configurations": ["Launch Egg", "Attach Agent", "Attach Worker"]
    }
  ]
}

As V8 Debugger Legacy Protocol will be removed after Node.js 8.x, And replace the use of Inspector Protocol

The new protocol has three major advantages:

  1. Support very large JavaScript object
  2. Support ES6 Proxy
  3. Support Source Map better

For and only for Node.js >= 7.x we should use Inspector Protocol for debugging.

In the above debug configuration, you need to modify some parameters to open the new protocol:

  • Launch Egg adjust the parameter "runtimeArgs": ["run", "debug"]
  • Attach Worker add the parameter "protocol": "inspector"

In addition, if you use the new protocol can also use chrome devtools for debugging, debugging address:

chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:10087
4. Start debugging

In VSCode, switch to the debug page. Select the Debug Egg configuration to start.

More VSCode Debug usage can be found in the documentation: Node.js Debugging in VS Code

Questions & Suggestions

Please open an issue here.

License

MIT

egg-development-proxyworker's People

Contributors

atian25 avatar okoala avatar tqcenglish avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.