Calling a remote process without a shared file system

(nodeA@foo.hyd.com)8> spawn(nodeA@bar.del.com, tut, test, [hello, 5]).

I want to create a process on bar.del.com that does not have access to the file system on foo.hyd.com (where am I creating this process) by running the "test" routine of the "tut" module.

Is there any way to do this without providing nodeA@bar.del.com with the compiled tut module file?

+3
source share
3 answers

You can use the following function to load a module on a remote node without providing the file itself:

load_module(Node, Module) ->
    {_Module, Bin, Filename} = code:get_object_code(Module), 
    rpc:call(Node, code, load_binary, [Module, Filename, Bin]).

code:load_binary/3 Filename, , , , _.

+3

*.beams .

, nl(Mod) erl ( ) . , nodes().

, .

node slave. . , , test:tut/2.

+3

You can send local code to the remote node:

> {Mod, Bin, File} = code:get_object_code(Module).
> rpc:call(RemoteNode, code, load_binary, [Mod, File, Bin]).
0
source

Source: https://habr.com/ru/post/1726335/


All Articles