How to set default name for node in Elixir?

I am working on some common code in Elixir, however I need to pass pass -name to name my node. Is there anyway to do this by default? I would like to set something in my .elixirrc file so that each server always has the same node name.

+4
source share
2 answers

The short answer is no.

The long answer: you can assign a name to node dynamically, so if you find that you are performing many configuration tasks (setting cookies, name nodes, etc.), you can have a script to help you get started. You will need Elixir v0.10.1 (currently the wizard):

# boot.exs :net_kernel.start([:foobar, :shortnames]) 

And then run it:

 $ mix run boot.exs 

Documents for net_kernel can be found here .

+6
source
 Node.start(:"foobar", :shortnames) 

or if you want to use longname

 Node.start(:" foobar@172.17.0.1 ") 

Assuming an IP address of 172.17.0.1. This should be the IP address of the machine on which you want to create your node.

You can access this node simply by running Node.self

0
source

Source: https://habr.com/ru/post/1492398/


All Articles