[erlang-questions] Forcing `erl` not to start `epmd` OS process but starting `erl_epmd` process

Ciprian Dorin Craciun ciprian.craciun@REDACTED
Fri Oct 21 18:41:07 CEST 2011


On Fri, Oct 21, 2011 at 19:29, Kenneth Lundin <kenneth.lundin@REDACTED> wrote:
> Just start epmd yourself before start of Erlang nodes
>
> Kenneth/


    Yes, I do start `epmd`, but regardless `erlexec.c` insists on
starting it's own instance, which dies (silently) because it fails to
bind on the same port.

    For example:
~~~~
strace -f -e process erl -name test -noinput -run init stop 2>&1 | grep execve
~~~~
execve("/usr/bin/erl", ["erl", "-name", "test", "-noinput", "-run",
"init", "stop"], [/* 47 vars */]) = 0
...
[pid 13133] execve("/usr/lib/erlang/erts-5.8.5/bin/epmd",
["/usr/lib/erlang/erts-5.8.5/bin/e"..., "-daemon"], [/* 49 vars */]) =
0
[pid 13129] execve("/usr/lib/erlang/erts-5.8.5/bin/beam.smp",
["/usr/lib/erlang/erts-5.8.5/bin/b"..., "--", "-root",
"/usr/lib/erlang", "-progname", "erl", "--", "-home", "/home/ciprian",
"--", "-name", "test", "-noshell", "-noinput", "-run", "init", ...],
[/* 48 vars */]) = 0
~~~~

    I want to force erl not to try to start epmd itself.

    As explained there is an `-no_epmd` option which forces
`erlexec.c` not to start epmd, but at the same time it breaks
`erl_distribution.erl` by not starting the `erl_epmd` gen server which
is used by `inet_tcp_dist` to resolve the other nodes.

    Ciprian.


> Den 20 okt 2011 07.20, "Ciprian Dorin Craciun" <ciprian.craciun@REDACTED>
> skrev:
>
>    Hello all!
>
>    I'm using Erlang in a context where I want to "manually" start and
> manage the EPMD OS process (for the usage of distributed Erlang
> nodes). (By manually I mean as part of an OS related supervisor tree,
> but not started by the erl interpreter.)
>
>    Now after searching the Internet and the latest OTP sources, I
> haven't found a way to properly do this. This is what I've found:
>    * you could specify `-no_epmd` as an argument for the `erl`
> invocation, which stops `erlexec.c` from executing `epmd`;
>    * unfortunately specifying `-no_epmd` also stops
> `erl_distribution` to start by default `erl_epmd` gen_server process
> which is needed by `inet_tcp_dist`;
>
>    A possible workaround I've found is to do the following (which I
> think it is actually a bug):
>    * add `-no_epmd whatever` to `erl` arguments; (it seems that
> `erlexec.c` searches for `no_epmd` which sets an internal flag, but
> also copies the whole argument to be read by `init:get_argument`);
>    * doing this (adding `whatever`) makes
> `init:get_argument(no_epmd)` return `{ok, [["whatever"]]` which
> "fools" `erl_distribution` into thinking that `no_epmd` wasn't set (it
> has a case with only the `{ok, [[]]}` and `_`);
>
>    Also I've noticed that `erl_distribution` then uses the
> `net_kernel:epmd_module()` fuction to find out the module to start.
> There is an argument `-epmd_module` which could allow to change the
> default module, but unfortunately there is a bug: it just returns the
> string obtained directly from `init:get_argument`, which isn't an
> atom, and thus it crashes the interpreter. Shouldn't it use
> `list_to_atom`? (I'm almost certainly this is a bug. To check it just
> run `erl` and ask for `net_kernel:epmd_module().`, then run `erl
> -epmd_module whatever`, and ask again `net_kernel`.)
>
>    Thanks for your feedback,
>    Ciprian.



More information about the erlang-questions mailing list