私は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}.