[erlang-questions] net_kernel:start/1 doesn't honor ERL_EPMD_PORT set by os:putenv/2
Tue Mar 15 13:29:18 CET 2016
net_kernel:start is looking at the init value of the EPMD port (the one
specified when erlang was started), so changing the environment variable
in Erlang like this doesn't have any effect. I agree that it would
probably be more intuitive if it worked as you describe, so please
submit a feature request to bugs.erlang.org <http://bugs.erlang.org> (or
if you have found any documentation saying that it should work as you
say, please submit it as a bug and point to the documentation), and
we'll look into it as soon as we get time to do so.
If you want to contribute with a change for this, which you are very
welcome to do, please look at the code in lib/kernel/src/erl_epmd.erl.
Make sure to think it through though, for example by handling the case
when the port environment variable is changed when the distribution is
already started. :)
On 03/11/2016 05:48 AM, Khitai Pang wrote:
> I have the following code:
> os:putenv("ERL_EPMD_ADDRESS", inet_parse:ntoa(IP)),
> os:putenv("ERL_EPMD_PORT", integer_to_list(5555)),
> os:cmd("epmd -daemon"),
> net_kernel:start([bob, longnames]),
> The ERL_EPMD_ADDRESS and ERL_EPMD_PORT environment variables are used
> by os:cmd("epmd -daemon") but net_kernel:start/1 fails:
> Protocol: "inet_tcp": register/listen error: econnrefused
> Apparently it still tries to connect to 4369, where no process is
> If I start erl by "ERL_EPMD_PORT=5555 erl", net_kernel:start/1 in the
> above code works fine.
> So I have come to the conclusion that environment variables set by
> os:putenv/2 are not honored by net_kernel:start/1. Am I right? If
> yes, 1) is this a bug? 2) for a Erlang/OTP release, how to
> automatically set global environment variables for erl?
> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions