vscode-elixir-ls icon indicating copy to clipboard operation
vscode-elixir-ls copied to clipboard

Support debug with user defined node full name

Open mjaric opened this issue 4 years ago • 1 comments

As described in issue here https://github.com/JakeBecker/vscode-elixir-ls/issues/97 one would like to debug erlang/elixir node that is part of some cluster. I suggested to respect ERL OPTIONS env variable so it can be injected on application start.

Here is launch config I suggested

{
      "type": "mix_task",
      "name": "mix phx.server",
      "request": "launch",
      "projectDir": "${workspaceRoot}",
      "task": "phx.server",
      "startApps": true,
      "env":{
        "ELIXIR_ERL_OPTIONS": "-name [email protected]"
      }
}

At the moment, LS will never connect to node since this VS Code plugin will generate node name anyways and pass it to LS, and above would only make confusion. Probably it is the best way to be explicit in launch confing with dedicated attribute for sname or name flag for instance

{
     "type": "mix_task",
     "name": "mix phx.server",
     "request": "launch",
     "projectDir": "${workspaceRoot}",
     "task": "phx.server",
     "startApps": true,
     "nodeName": "[email protected]"
}

EDIT:

For the sake of the safety if node should connect to prod cluster, there can be also flag for "hidden" and nodeCookie, in case one would like to run hidden node in the cluster with all code up but don't want that node to participate in cluster workload.

{
     "type": "mix_task",
     "name": "mix phx.server",
     "request": "launch",
     "projectDir": "${workspaceRoot}",
     "task": "phx.server",
     "startApps": true,
     "erlOpts": {
           "name": "[email protected]",
           "cookie": "dskajhd98asd9ohasdh98hsad9",
           "hidden": true
     }
}

the list could go on :) for any erl flag

mjaric avatar Sep 13 '19 09:09 mjaric

A PR would be welcome

lukaszsamson avatar Sep 30 '20 16:09 lukaszsamson

hi, three years passed, is there any process on it?

ziyouchutuwenwu avatar Nov 15 '22 01:11 ziyouchutuwenwu

No but my answer still stands

lukaszsamson avatar Nov 15 '22 07:11 lukaszsamson

hi, @mjaric , i now use this configuratoin, it seems to be working

{
      "type": "mix_task",
      "name": "debug",
      "request": "launch",
      "task": "run",
      "taskArgs": [
        "-e",
        // :shortnames, :longnames
        ":net_kernel.start([:debug, :shortnames])",
        "-e",
        ":erlang.set_cookie(node(), :\"123456\")",
        "-e",
        "Demo.hello()"
      ],
      "startApps": true,
      "preLaunchTask": "epmd",
      "projectDir": "${workspaceRoot}",
    }

tasks.json

{
      "label": "epmd",
      "type": "shell",
      // kill -9 `pidof epmd`
      "command": "epmd -daemon"
    }

ziyouchutuwenwu avatar Dec 04 '22 09:12 ziyouchutuwenwu

ELS_ELIXIR_OPTS and ELS_ERL_OPTS are now supported. You can pass --sname --cookie mycookie via ELS_ELIXIR_OPTS. I believe this issue is now resolved.

lukaszsamson avatar Jun 22 '23 11:06 lukaszsamson