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

Support for remote dev-server #41

Open
crycode-de opened this issue May 3, 2021 · 0 comments
Open

Support for remote dev-server #41

crycode-de opened this issue May 3, 2021 · 0 comments

Comments

@crycode-de
Copy link

As discussed in a chat with @UncleSamSwiss, it would be nice if dev-server can be used remote.
This would be very useful especially for embedded systems (like a Raspberry Pi). So you can run your dev environment on your (powerfull) desktop PC and test the adapter on the remote embedded system, maybe with special hardware attached.

Possible setup and run

dev-server setup --remote pi@192.168.1.50
dev-server watch --remote pi@192.168.1.50

The files which will be included in the npm package should be synced to the remote on change.

Debugging

For debugging it should be possible to attach a debugger (like vscode-js-debug).

The adapter node process has to be started with the additional arguments:

  • --inspect-brk=0.0.0.0:9229 or --inspect=0.0.0.0:9229 (maybe with -brk, the IP and the port configurable)
  • --nolazy (needed for correct breakpoint locations at startup)

For TypeScript adapters, "inlineSourceMap": true have to be set in tsconfig.json.
Using the "normal" "sourceMap": true option, I wasn't able to get the sourcemaps running for remote debugging. The breakpoints are set in the remote process, but not mapped back to the sources in VSCode and only the build js files were shown.

To check the VSCode debugger session setup, you may run "Debug: Create Diagnostic Information for Current Session" from the command palette and then select "Why my breakpoints don't bind". If there are three green check marks you are fine.

The source files (from src/) are not needed on the remote system. The mapping from the build files to the source files is performed in VSCode.

The launch.json to attach the debugger may look like:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "protocol": "inspector",
      "request": "attach",
      "name": "Attach Remote",
      "address": "192.168.1.50",
      "port": 9229,
      "smartStep": true,
      "skipFiles": [
        "<node_internals>/**"
      ],
      "outFiles": [ // for TypeScript adapters
        "${workspaceFolder}/build/**/*.js"
      ],
      "sourceMaps": true, // for TypeScript adapters
      "localRoot": "${workspaceFolder}",
      "remoteRoot": "/opt/iobroker/node_modules/iobroker.canbus", // full path to remote adapter directory
      "trace": true
    }
  ],
}

localRoot and remoteRoot are needed for correct mapping of the remote URLs provided by the debugger to the locals URLs in your workspace.
address and port may be defined using the ${inputs:xxx} syntax for a more flexible setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant