开发者

Starting an Erlang slave node in escript fails when using custom Erlang in Ubuntu 10.4

开发者 https://www.devze.com 2023-01-01 10:33 出处:网络
I have the following escript: #!/usr/bin/env escript %%! -name test_starter@127.0.0.1 main(_) -> NodeName = test,

I have the following escript:

#!/usr/bin/env escript
%%! -name test_starter@127.0.0.1

main(_) ->
    NodeName = test,
    Host = '127.0.0.1',
    Args = "",

    {ok, _Node} = slave:start_link(Host, NodeName, Args),
    io:format("Node started successfully!").

When running开发者_JAVA百科 it on Ubuntu 10.04 I get this:

$ ./start_slave
Node started successfully!
$

I want to install my own Erlang (latest version, debug compiled files for dialyzer etc) since the stock install of Erlang on Ubuntu lacks some features. I put my Erlang binaries inside ~/Applications/bin. Starting Erlang normally works, and starting slave nodes inside an Erlang shell works as well.

However, now my escript doesn't work. After about 60 seconds it returns an error:

$ ./start_slave                                   
escript: exception error: no match of right hand side value {error,timeout}

Even if I change the first line to the escript to use my erlang version, it still does not work:

#!/home/user/Applications/bin/escript

The slave node is started with a call to erlang:open_port/2 which seems to be using sh which in turn does not read my .bashrc file that sets my custom PATH environment variable. The timeout seems to occur when slave:start_link/3 waits for the slave node to respond, which it never does.

How can I roll my own installation of Erlang and start slave nodes inside escripts on Ubuntu 10.4?

Update: I've tried to add the path to my custom Erlang inside /etc/environment (where the original PATH in Ubuntu is set) but this does not change anything...

Update 2: Accepting the only answer given (even though it didn't solve the problem). The Ubuntu and Erlang versions are a bit old now and this might not be an issue anymore.


Is it possible that the slave node is being run with the other Erlang install? Listed under reasons for timeout error in the documentation on slave nodes I saw "the Erlang nodes have different cookies" which might, I believe, occur in that case.

If this were the case, running ps -FC erlang while it's waiting for the timeout should show you processes with different paths.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号