0
votes

I have a laptop that uses a VPN, and my hostname often changes. I get a different Erlang node name every time this happens. The docs for node (http://erlang.org/doc/reference_manual/distributed.html) do not seem to specify a way to set this statically.

How can I permanently configure my machine's nodename to be persistent across network changes?

2
Could -sname flag for the erl command work for you?Asier Azkuenaga
@AsierAzkuenaga no because this doesn't get launched using erl. Is there a way to set this as an enviornmental variable?Tommy
How is it launched?Asier Azkuenaga
Through a rebar/relx release.Tommy
And sometimes during a common test using rebar3 ctTommy

2 Answers

1
votes

If you are using Rebar, you should have a vm.args somewhere and you can set the -sname my_permanent_node_name flag in here.

Note that no communication can exist between nodes running with flag -sname and those running with flag -name.

1
votes

Will still accept Asier's answer as it solved it for running normally.

Adding this because when running rebar3 ct, I hit this issue: http://erlang.org/pipermail/erlang-questions/2016-March/088414.html. That is, rebar3 ct does not respect the rebar.config node name. I was able to solve this problem using an answer in that mailing thread:

set -x REBAR3_ERL_ARGS "-sname myapp@localhost"; rebar3 local install; env DEBUG=1 ~/.cache/rebar3/bin/rebar3 ct

So combined with these two answers I solved the problem.