Skip to content

Instantly share code, notes, and snippets.

@alvises
Created November 22, 2019 17:42
Show Gist options
  • Save alvises/ffe85b4d697ce6f71fdc8487e38a007f to your computer and use it in GitHub Desktop.
Save alvises/ffe85b4d697ce6f71fdc8487e38a007f to your computer and use it in GitHub Desktop.
app.exs test script which connects two Elixir nodes running in two containers
IO.puts("I'm here! Sleeping for 2 seconds")
Process.sleep 2_000 # waiting for the other node
nodes = MapSet.new([:app@app1, :app@app2])
other_node =
nodes
|> MapSet.delete(Node.self())
|> MapSet.to_list()
|> List.first()
|> IO.inspect(label: "[self is #{inspect(Node.self)}]")
Node.connect(other_node) |> IO.inspect(label: "connect (from #{inspect(Node.self)}")
Process.sleep 2_000
Node.list() |> IO.inspect(label: "nodes")
Enum.each 1..5, fn _ ->
Node.ping(other_node)
|> IO.inspect(label: "ping #{inspect(other_node)}")
Process.sleep(1_000)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment