Skip to content

Commit 87e5c6c

Browse files
committed
Monitor remote nodes in attach mode
1 parent 77fcebb commit 87e5c6c

File tree

1 file changed

+23
-1
lines changed
  • apps/debug_adapter/lib/debug_adapter

1 file changed

+23
-1
lines changed

apps/debug_adapter/lib/debug_adapter/server.ex

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,12 +630,28 @@ defmodule ElixirLS.DebugAdapter.Server do
630630
{:noreply, state}
631631
end
632632

633+
def handle_info({:nodeup, node, %{node_type: node_type}}, state = %__MODULE__{}) do
634+
Output.debugger_console("#{node_type} node #{node} connected\n")
635+
{:noreply, state}
636+
end
637+
638+
def handle_info(
639+
{:nodedown, node, %{node_type: node_type, nodedown_reason: nodedown_reason}},
640+
state = %__MODULE__{}
641+
) do
642+
Output.debugger_console(
643+
"#{node_type} node #{node} disconnected: #{inspect(nodedown_reason)}\n"
644+
)
645+
646+
{:noreply, state}
647+
end
648+
633649
# If we get the disconnect request from the client, we continue with :disconnect so the server will
634650
# die right after responding to the request
635651
@impl GenServer
636652
def handle_continue(:disconnect, state = %__MODULE__{}) do
637653
unless :persistent_term.get(:debug_adapter_test_mode, false) do
638-
Output.debugger_console("Received disconnect request")
654+
Output.debugger_console("Received disconnect request\n")
639655
Process.sleep(200)
640656
System.stop(0)
641657
else
@@ -806,6 +822,12 @@ defmodule ElixirLS.DebugAdapter.Server do
806822
defp handle_request(attach_req(_, config), state = %__MODULE__{}) do
807823
server = self()
808824

825+
:net_kernel.monitor_nodes(true, %{
826+
connection_id: false,
827+
node_type: :all,
828+
nodedown_reason: true
829+
})
830+
809831
{_, ref} = spawn_monitor(fn -> attach(config, server) end)
810832

811833
config =

0 commit comments

Comments
 (0)