Skip to content

Instantly share code, notes, and snippets.

@mazz
Forked from alvises/app.exs
Created December 5, 2022 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mazz/14c9bb01b22972b8dec61b94281ebb13 to your computer and use it in GitHub Desktop.
Save mazz/14c9bb01b22972b8dec61b94281ebb13 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