[erlang-questions] Autogenerating node names
David Sveningsson
ext@REDACTED
Thu Dec 11 14:26:25 CET 2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi, I am trying to autogenerate names for nodes if they aren't given one
with -sname or -name. I've got it (partial) working with the following code:
Name = foo:generate_name(),
case net_kernel:start([Name, shortnames]) of
{ok, _Pid} ->
init();
{error, Reason} ->
io:format("Node isn't alive and failed to autogenerate a name:~n~p~n",
[Reason])
end;
Now, this works as long as epmd has already been started. If not it
fails with:
{shutdown,{child,undefined,net_sup_dynamic,
{erl_distribution,start_link,
[['Node_B184E4E0@REDACTED',shortnames]]},
permanent,1000,supervisor,
[erl_distribution]}}
=INFO REPORT==== 4-Dec-2008::10:17:46 ===
Protocol: "inet_tcp": register error: {{badmatch,{error,econnrefused}},
[{inet_tcp_dist,listen,1},
{net_kernel,start_protos,4},
{net_kernel,start_protos,3},
{net_kernel,init_node,2},
{net_kernel,init,1},
{gen_server,init_it,6},
{proc_lib,init_p_do_apply,3}]}
Is there a simpler way to autogenerate names or is there a way to start
epmd automatically (as it does when using -sname or -name)?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAklBFQEACgkQ6pa1H/H5pqX3dQCfSrw8nSxLoXv81NIpsjzRTCK4
URIAniqKYl2xiJ4rg+IN4MT9BZwUmGaD
=vLAk
-----END PGP SIGNATURE-----
More information about the erlang-questions
mailing list