简体   繁体   English

无法在Erlang中的另一个节点上生成进程

[英]Unable to spawn process on another node in Erlang

When I try to create a new process on separate node using 当我尝试使用以下方法在单独的节点上创建新进程时

Pid = spawn(mynode, mymodule, myfunction, [self()])

( myfunction/1 is exported), I get this error: myfunction/1已导出),出现此错误:

Error in process <0.10.0> on node 'no@de1' with exit value:
{undef,[{mymodule, myfunction, [<33.64.0>], []}]}

I tried to set -compile(export_all) flag, but assuming the additional braces in error log, this is not the case. 我尝试设置-compile(export_all)标志,但是假设错误日志中有其他花括号,则不是这种情况。 I don't know what causes the error and I have no clue what to do. 我不知道是什么导致错误,也不知道该怎么办。

The error you get is saying “There is no module 'mymodule' and/or no function 'mymodule:myfunction/1'”. 您得到的错误是“没有模块'mymodule'和/或没有函数'mymodule:myfunction / 1'”。
This means mymodule is not loaded in the code server of your separate node. 这意味着mymodule尚未加载到单独节点的代码服务器中。
To load mymodule's code there you need something like this snippet or this function 要加载mymodule的代码,您需要类似此代码段此函数的内容

Did you check that the module mymodule is in the path of no@de1? 您是否检查模块mymodule在no @ de1的路径中?

When you spwan a process using spawn(mynode, mymodule, myfunction, [self()]), the VM needs to load the code before executing it. 使用spawn(mynode,mymodule,myfunction,[self()])刷新进程时,VM需要在执行代码之前先加载代码。

If you use a high order function (a fun) in this way spawn(Node, Fun) , then in is not more necessary to have the code in the path (but beware that any call to a function in the function definition need to be solved on the remote node) 如果以这种方式使用spawn(Node, Fun)这样的高阶函数(一个有趣的函数spawn(Node, Fun) ,则在路径中包含代码并不是必须的(但要注意,在函数定义中对函数的任何调用都必须是在远程节点上解决)

go to no@de1 and run m(mymodule). 转到no @ de1并运行m(mymodule). It should clarify if the module is loadable and which functions does export. 它应阐明该模块是否可加载以及导出哪些功能。

also: check if the other node is reachable. 还:检查另一个节点是否可达。 Do a net_adm:ping on it. 在其上执行net_adm:ping

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM