首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >主控引擎重新启动策略和子规范

主控引擎重新启动策略和子规范
EN

Stack Overflow用户
提问于 2012-11-19 05:22:50
回答 1查看 418关注 0票数 0

我正在阅读rabbitmq的supervisor2.erl,rabbit_channel_sup_sup.erl, rabbit_channel_sup.erl源代码。

childspec的start参数为"temporary"时,表示该子进程在任何原因退出后都不会重启,对吗?

当start参数为"temporary"时,每个重新启动参数one-for-one, one-for-all,one-for-rest,simple-one-for-one都没有区别。因为代码运行结果是相同的。是对的吗?

以下代码来自supervisor2.erl文件

代码语言:javascript
复制
do_restart({permanent = RestartType, Delay}, Reason, Child, State) ->
    do_restart_delay({RestartType, Delay}, Reason, Child, State);
do_restart(permanent, Reason, Child, State) ->
    report_error(child_terminated, Reason, Child, State#state.name),
    restart(Child, State);
do_restart(Type, normal, Child, State) ->
    del_child_and_maybe_shutdown(Type, Child, State);
do_restart({RestartType, Delay}, {shutdown, restart} = Reason, Child, State)
  when RestartType =:= transient orelse RestartType =:= intrinsic ->
    do_restart_delay({RestartType, Delay}, Reason, Child, State);
do_restart(Type, {shutdown, _}, Child, State) ->
    del_child_and_maybe_shutdown(Type, Child, State);
do_restart(Type, shutdown, Child = #child{child_type = supervisor}, State) ->
    del_child_and_maybe_shutdown(Type, Child, State);
do_restart({RestartType, Delay}, Reason, Child, State)
  when RestartType =:= transient orelse RestartType =:= intrinsic ->
    do_restart_delay({RestartType, Delay}, Reason, Child, State);
do_restart(Type, Reason, Child, State) when Type =:= transient orelse
                                            Type =:= intrinsic ->
    report_error(child_terminated, Reason, Child, State#state.name),
    restart(Child, State);
do_restart(temporary, Reason, Child, State) ->  %%<<----attention here, just report_error,not calling restart child function
    report_error(child_terminated, Reason, Child, State#state.name),
    NState = state_del_child(Child, State),
    {ok, NState}.
EN

回答 1

Stack Overflow用户

发布于 2012-11-19 07:43:37

临时子进程永远不会重启,这是真的。但重启策略仍然在决定主管行为方面发挥作用- all-for-one策略将杀死所有孩子(不会重启,因为他们是暂时的),而one_for_one不会杀死任何其他孩子。基本上,这些重启策略告诉管理程序如何处理其他进程(其他进程是未死的进程),因此是有区别的。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13444742

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档