Skip to content

Commit

Permalink
feat: only ping when monitoring
Browse files Browse the repository at this point in the history
  • Loading branch information
feng19 committed Mar 7, 2024
1 parent c1f740f commit e03ed09
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/x_trace/node_listener.ex
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ defmodule XTrace.NodeListener do
def init(_) do
init_erlang_distributed()
:timer.send_interval(1000, self(), :tick)
{:ok, nil}
{:ok, false}
end

@impl true
Expand All @@ -38,7 +38,7 @@ defmodule XTrace.NodeListener do
end

def handle_info(:tick, state) do
:net_adm.world()
if state, do: :net_adm.world()
{:noreply, state}
end

Expand All @@ -48,11 +48,11 @@ defmodule XTrace.NodeListener do
end

@impl true
def handle_call({:monitor, bool}, _from, state) do
def handle_call({:monitor, bool}, _from, _state) do
# ping world nodes
:net_adm.world()
:net_kernel.monitor_nodes(bool, node_type: :all)
{:reply, :ok, state}
{:reply, :ok, bool}
end

defp init_erlang_distributed do
Expand Down

0 comments on commit e03ed09

Please sign in to comment.