Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spawn remote process w/o common file system

([email protected])8> spawn([email protected], tut, test, [hello, 5]).

I want to spawn a process on bar.del.com which has no file system access to foo.hyd.com (from where I am spawning the process), running subroutine "test" of module "tut".

Is there a way to do so, w/o providing the [email protected] with the compiled "tut" module file?

like image 905
baskin Avatar asked Jan 22 '23 20:01

baskin


1 Answers

You can use the following function to load a module at 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]).

As noted in code:load_binary/3 Filename argument is used only to track the path to module and the file it points to is not used by local node_server.

like image 199
gleber Avatar answered Feb 04 '23 21:02

gleber