[erlang-questions] How to distribute code using code server to slave nodes (II)

Angel Alvarez clist@REDACTED
Wed Jul 22 14:05:12 CEST 2009


Hi

stdlib/slave.erl

function wait_for_slave has a timeout of 32 milliseconds that seem to be too short for a whole node startup sequence (on WLAN 54Mbits).

Ill try to copy this module to private path and rename to myslave so altering the after clause dont mess with standard
module and see wahts happens...


wait_for_slave(Parent, Host, Name, Node, Args, LinkTo, Prog) ->
    Waiter = register_unique_name(0),
    case mk_cmd(Host, Name, Args, Waiter, Prog) of
        {ok, Cmd} ->
%%          io:format("Command: ~s~n", [Cmd]),
            open_port({spawn, Cmd}, [stream]),
            receive
                {SlavePid, slave_started} ->
                    unregister(Waiter),
                    slave_started(Parent, LinkTo, SlavePid)
            after 32000 ->
                    %% If it seems that the node was partially started,
                    %% try to kill it.
                    Node = list_to_atom(lists:concat([Name, "@", Host])),
                    case net_adm:ping(Node) of
                        pong ->
                            spawn(Node, erlang, halt, []),
                            ok;
                        _ ->
                            ok
                    end,
                    Parent ! {result, {error, timeout}}
            end;
        Other ->
            Parent ! {result, Other}
    end.


Regards /angel

El Miércoles, 22 de Julio de 2009 Angel escribió:
> Hi again
> 
> More on this issue ive managed to start a remote node using the code server
> 
> start erlang in distribute mode.. on the Master Node.
> 
> start the code server...
> code_server4:start( MyRemoteSlave).
> 
> and finally  
> 
> slave:start(MyRemoteSlave,Nost,Name,SomeArgs).
> 
> where SomeArgs contains "-setcookie mycookie and -hosts <master node IP> -loader inet"
> 
> resulting in a timeout failure to start and setup the remote slave.
> 
> But if i logon on the slave node and do...
> 
> sinosuke@REDACTED:~> erl -hosts <MasterIP> -loader inet -id one@<MyRemoteSlave> -name one@<MyRemoteSlave> -setcookie mycookie
> 
> ¡¡it success!!
> 
> Erlang R13B01 (erts-5.7.2) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]
> 
> Eshell V5.7.2  (abort with ^G)
> (one@REDACTED)1>
> 
> 
> tcpdump shows network activity while the remote code server ask Master code server for the required stuff..
> (adding +l to erl cmdline show remote code loading)
> 
> So the aproach is correct but the remote node fails to load all the required code in time and the slave module on the master
> complains about timeout.
> 
> ¿¿Can i tweak this timeout value in order to let the remote node finish its code loading??      
> 
> I whant to use "-loader inet" to avoid having to deploy my app code all over the remote nodes by hand.
> 
> Regards Angel
> 
> 
> El Miércoles, 22 de Julio de 2009 00:06:06 Angel Alvarez escribió:
> > Hi
> > 
> > Im learning erlang so i use to write toy programs just for fun
> > now Im learning to use the pool module, so i cant spread workers over some computers.
> > 
> > The problem is that prior to pspawn processes i have to manually distribute code among all members of the pool.
> > I use to write something like this (i saw this somewhere on the net...)
> > 
> > 	pool:start(pooltest, lists:concat(["-setcookie ", erlang:get_cookie()])),
> > 	distribute_app([mymodule1,mymodule2, ... , mymodulen]),
> > 
> > 
> > with distribute_app as:
> > 
> > distribute_app(Modules) ->
> >         %% extraer todos los nodos excepto el Master
> >         RemoteNodes = [X || X <- pool:get_nodes(), X =/= node()],
> >         %% Transferir el código
> >         lists:foreach(fun(Node) -> transfer_code(Node, Modules) end, RemoteNodes).
> > 
> > transfer_code(Node, Modules) ->
> >         [transfer_module(Node, Module) || Module <- Modules].
> > 
> > transfer_module(Node, Module) ->
> >         {_Module, Binary, FileName} = code:get_object_code(Module),
> >         rpc:call(Node, code, load_binary, [Module, FileName, Binary]).
> > 
> > Instead of doing this, can i instruct remote code servers to ask master code server for code when
> > it need to locate new refences?
> > 
> > Is seems to be related to starting erl with "--loader inet" ¿Can anyone prove me with some pointers about this? 
> > 
> > Thanks
> > 
> 
> 
> 



-- 
Agua para todo? No, Agua para Todos.
->>-----------------------------------------------
    Clist UAH a.k.a Angel
---------------------------------[www.uah.es]-<<--

Güindous 7 será peor y con más DRM, asi que usa Linux y disfruta de la vida


More information about the erlang-questions mailing list