我正在阅读rabbitmq的supervisor2.erl,rabbit_channel_sup_sup.erl, rabbit_channel_sup.erl
源代码。
当childspec
start 参数为"temporary"
时,表示子进程在任何原因退出后都不会重新启动。这样对吗?
当启动参数为"temporary"
时,每个重启参数没有区别,one-for-one, one-for-all,one-for-rest,simple-one-for-one
。因为代码运行结果是一样的。这样对吗?
以下代码来自supervisor2.erl
文件
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}.