在 Ubuntu 10.4 中使用自定义 Erlang 时,在 escript 中启动 Erlang 从属节点失败
我有以下脚本:
#!/usr/bin/env escript
%%! -name [email protected]
main(_) ->
NodeName = test,
Host = '127.0.0.1',
Args = "",
{ok, _Node} = slave:start_link(Host, NodeName, Args),
io:format("Node started successfully!").
在 Ubuntu 10.04 上运行它时,我得到这个:
$ ./start_slave
Node started successfully!
$
我想安装我自己的 Erlang(最新版本,调试透析器的编译文件等),因为 Ubuntu 上的 Erlang 的库存安装缺少一些功能。我将 Erlang 二进制文件放入 ~/Applications/bin
中。启动 Erlang 通常可以工作,并且在 Erlang shell 内启动从属节点也可以工作。
然而,现在我的脚本不起作用了。大约 60 秒后,它返回一个错误:
$ ./start_slave
escript: exception error: no match of right hand side value {error,timeout}
即使我将第一行更改为 escript 以使用我的 erlang 版本,它仍然不起作用:
#!/home/user/Applications/bin/escript
从属节点通过调用 erlang:open_port/2
启动code> 似乎正在使用 sh
,而它又不会读取设置自定义 PATH
环境变量的 .bashrc
文件。当 slave:start_link/3
等待从节点响应时,似乎会发生超时,但它从未这样做。
如何在 Ubuntu 10.4 上自行安装 Erlang 并在 escripts 内启动从属节点?
更新: 我已尝试在 中添加自定义 Erlang 的路径>/etc/environment
(Ubuntu 中原始 PATH
的设置位置),但这不会改变任何内容...
更新 2: 接受给出的唯一答案(尽管它没有解决问题)。 Ubuntu 和 Erlang 版本现在有点旧,这可能不再是问题。
I have the following escript:
#!/usr/bin/env escript
%%! -name [email protected]
main(_) ->
NodeName = test,
Host = '127.0.0.1',
Args = "",
{ok, _Node} = slave:start_link(Host, NodeName, Args),
io:format("Node started successfully!").
When running 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从属节点是否可能与其他 Erlang 安装一起运行?在从节点文档中列出了超时错误的原因,我看到“ Erlang 节点有不同的 cookie”,我相信,在这种情况下可能会发生这种情况。
如果是这种情况,在等待超时时运行
ps -FC erlang
应该会显示具有不同路径的进程。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.