Remote Code Load

From Erlang Community

(Difference between revisions)
Revision as of 20:32, 11 January 2007 (edit)
Patricknharris (Talk | contribs)

← Previous diff
Current revision (14:05, 17 October 2009) (edit) (undo)
Snickl (Talk | contribs)
m (Fix invocation of load_binary)
 
Line 12: Line 12:
%% and load it on all connected nodes including this one; %% and load it on all connected nodes including this one;
%% the next time the code is called it will be using the new version %% the next time the code is called it will be using the new version
-{Replies, _} = rpc:multicall(code, load_binary, [Mod, Bin, File,]),+{Replies, _} = rpc:multicall(code, load_binary, [Mod, File, Bin]),
%% if this node were the "master/admin" node %% if this node were the "master/admin" node
%% then to push to everything but this node use: %% then to push to everything but this node use:
-%% {Replies, _} = rpc:multicall(nodes(), code, load_binary, [Mod, Bin, File,]),+%% {Replies, _} = rpc:multicall(nodes(), code, load_binary, [Mod, File, Bin]),
%% and then maybe check the Replies list. %% and then maybe check the Replies list.

Current revision

[edit] Problem

Remote Load New Code to All Nodes

[edit] Solution

Solution attribution: this example is buried in erlang rpc multicall doc.

%% Find object code for module Mod 
{Mod, Bin, File} = code:get_object_code(Mod), 

%% and load it on all connected nodes including this one; 
%% the next time the code is called it will be using the new version
{Replies, _} = rpc:multicall(code, load_binary, [Mod, File, Bin]),

%% if this node were the "master/admin" node
%% then to push to everything but this node use:
%% {Replies, _} = rpc:multicall(nodes(), code, load_binary, [Mod, File, Bin]),

%% and then maybe check the Replies list.

[edit] Discussion

This sort of change is tedious within other network infrastructures. see erlang.org rpc multicall doc for further details.

Erlang/OTP Projects
Personal tools