[erlang-questions] Autogenerating node names

Per Hedeland per@REDACTED
Fri Dec 12 00:24:18 CET 2008

David Sveningsson <ext@REDACTED> wrote:
>Thanks, but I was hoping to be able to skip the timer part. Does anyone
>know when epmd forks? Before or after its initialization?
>Let me rephrase that, is epmd ready when "epmd -daemon" returns or must
>one wait an unspecified time while it is starting?

I'd rephrase it as a suggestion, because it's a very nice way to
start up a daemon, but epmd doesn't do that - it forks first
(read the source:-). You can use erl_epmd:names/0 to check on
its presence/readiness though, e.g. something like this:

start_epmd() ->
    start_epmd(0, 10).

start_epmd(N, N) ->
    {error, too_many_tries};
start_epmd(M, N) ->
    case erl_epmd:names() of
	{ok, _} ->
	_ when M == 0 ->
	    os:cmd("epmd -daemon"),
	    start_epmd(M+1, N);
	_ ->
	    start_epmd(M+1, N)

Adjust "10" and "1" to taste, when I tried it I never managed to
get to the sleep...

--Per Hedeland

More information about the erlang-questions mailing list