release_handler底层指令 热部署的实际执行者

本文详细介绍了热部署过程中使用的低级指令及其应用场景。包括模块代码加载、进程暂停与恢复、代码变更等关键步骤,并探讨了不同指令组合对于旧版本代码及进程的影响。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

下面的指令是热部署干活的指令:

%%-----------------------------------------------------------------
%% An unpurged module is a module for which there exist an old
%% version of the code. This should only be the case if there are
%% processes running the old version of the code.
%%
%% This functions evaluates each instruction. Note that the
%% instructions here are low-level instructions. e.g. lelle's
%% old synchronized_change would be translated to
%% {load_object_code, Modules},
%% {suspend, Modules}, [{load, Module}],
%% {resume, Modules}, {purge, Modules}
%% Or, for example, if we want to do advanced external code change
%% on two modules that depend on each other, by killing them and
%% then restaring them, we could do:
%% {load_object_code, [Mod1, Mod2]},
%% % delete old version
%% {remove, {Mod1, brutal_purge}}, {remove, {Mod2, brutal_purge}},
%% % now, some procs migth be running prev current (now old) version
%% % kill them, and load new version
%% {load, {Mod1, brutal_purge}}, {load, {Mod2, brutal_purge}}
%% % now, there is one version of the code (new, current)
%%
%% NOTE: All load_object_code must be first in the script,
%% a point_of_no_return must be present (if load_object_code
%% is present).
%%
%% {load_object_code, {Lib, LibVsn, [Mod]}
%% read the files as binarys. do not make code out of them
%% {load, {Module, PrePurgeMethod, PostPurgeMethod}}
%% Module must have been load_object_code:ed. make code out of it
%% old procs && soft_purge => no new release
%% old procs && brutal_purge => old procs killed
%% The new old code will be gc:ed later on, if PostPurgeMethod =
%% soft_purge. If it is brutal_purge, the code is purged when
%% the release is made permanent.
%% {remove, {Module, PrePurgeMethod, PostPurgeMethod}}
%% make current version old. no current left.
%% old procs && soft_purge => no new release
%% old procs && brutal_purge => old procs killed
%% The new old code will be gc:ed later on, if PostPurgeMethod =
%% soft_purge. If it is brutal_purge, the code is purged when
%% the release is made permanent.
%% {purge, Modules}
%% kill all procs running old code, delete old code
%% {suspend, [Module | {Module, Timeout}]}
%% If a process doesn't repsond - never mind. It will be killed
%% later on (if a purge is performed).
%% Hmm, we must do something smart here... we should probably kill it,
%% but we cant, because its supervisor will restart it directly! Maybe
%% we should keep a list of those, call supervisor:terminate_child()
%% when all others are suspended, and call sup:restart_child() when the
%% others are resumed.
%% {code_change, [{Module, Extra}]}
%% {code_change, Mode, [{Module, Extra}]} Mode = up | down
%% Send code_change only to suspended procs running this code
%% {resume, [Module]}
%% resume all previously suspended processes
%% {stop, [Module]}
%% stop all procs running this code
%% {start, [Module]}
%% starts the procs that were previously stopped for this code.
%% Note that this will start processes in exactly the same place
%% in the suptree where there were procs previously.
%% {sync_nodes, Id, [Node]}
%% {sync_nodes, Id, {M, F, A}}
%% Synchronizes with the Nodes (or apply(M,F,A) == Nodes). All Nodes
%% must also exectue the same line. Waits for all these nodes to get
%% to this line.
%% point_of_no_return
%% restart_new_emulator
%% {stop_application, Appl} - Impl with apply
%% {unload_application, Appl} - Impl with {remove..}
%% {load_application, Appl} - Impl with {load..}
%% {start_application, Appl} - Impl with apply
%%-----------------------------------------------------------------

见release_handler_1.erl, 指令不是很多,基本上是bif的封装。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值