Hi,
i am trying to connect multiple nodes within elixir code but I gave up after trying multiple things.
node = :"main@127.0.0.1"
nodes_list = [:"n1@127.0.0.1", :"n2@127.0.0.1", :"n3@127.0.0.1", :"n4@127.0.0.1"]
Node.start(node)
Enum.each(nodes_list, fn node ->
Node.connect(node)
end)
Node.list() # its always empty.
Is there a way that I can start these nodes from code and then run a binary on that node from code?
Thanks
Hi,
does Node.connect/1
return true in your Enum.each/2
function?
And how did you start the nodes you want to connect to?
That’s the issue am facing, I don’t know how to start nodes inside the module.
Of course Node.connect/1
will return false because no nodes are started yet.
No, that’s as far as I know not possible without getting really hacky (e.g. starting it with System.cmd/3
).
Why do you need to spawn a new node from code?
There is :slave
to spawn additional nodes.
4 Likes