When using Elixir’s interactive shell IEx, I can create a node by command:
iex --sname node_name
But how can I create a node by code, then run the code by:
elixir code.exs
There are some function like node(), but it seems that those function just return a node existed.
Use
elixir --sname node_name
Generally, you pass the node name so that everything starts up knowing its own name. However, it is apparently also possible to set the name while running with the Erlang net_kernel module, as described in the answer to How set Erlang node name...
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