I'm working on some distributed code in Elixir, however, I have to keep passing --name to assign a name to my node. Is there anyway to do this by default? I'd like to set something in my .elixirrc file so that each server always has the same node name.
Short answer: no.
Long answer: you can given a name for a node dynamically, so if you find yourself doing many setup tasks (setting cookies, naming nodes, etc), you can have a script that helps you get it started. You will need Elixir v0.10.1 (currently master) for this:
# boot.exs
:net_kernel.start([:foobar, :shortnames])
And then start it:
$ mix run boot.exs
Docs for net_kernel can be found here.
Node.start(:"foobar", :shortnames)
or if you want to use longname
Node.start(:"[email protected]")
Assuming IP address 172.17.0.1. This has to be IP address of machine on which you want to create your node.
You can access this node by simply runningNode.self
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With