Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to change the name of a running Elixir node

I want to change the node name of a beam instance dynamically.

The usecase is in a cluster of VM's I would like the startup process to lookup the ip information and then pick a name from that.

node()
# => :nonode@nohost

# Lookup ip and change name

node()
# => :[email protected]
like image 264
Peter Saxton Avatar asked Oct 18 '25 06:10

Peter Saxton


1 Answers

Yes, you can use net_kernel:start/1 in Erlang or Node.start/{1,2,3} in Elixir:

1> node().
nonode@nohost
2> net_kernel:start(['[email protected]']).
{ok,<0.60.0>}
([email protected])3> node().
'[email protected]'
iex(1)> Node.self
:nonode@nohost
iex(2)> Node.start :"[email protected]"
{:ok, #PID<0.83.0>}
iex([email protected])3> Node.self
:"[email protected]"
like image 50
Dogbert Avatar answered Oct 21 '25 03:10

Dogbert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!