Skip to content

Commit b59948c

Browse files
author
Matthew Sackman
committed
Accomodate a desire to avoid polluting the logs
1 parent 78972a6 commit b59948c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/supervisor2.erl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@
3131
%% the MaxT and MaxR parameters to permit the child to be
3232
%% restarted. This may require waiting for longer than Delay.
3333
%%
34+
%% Sometimes, you may wish for a transient or intrinsic child to
35+
%% exit abnormally so that it gets restarted, but still log
36+
%% nothing. gen_server will log any exit reason other than
37+
%% 'normal', 'shutdown' or {'shutdown', _}. Thus the exit reason of
38+
%% {'shutdown', 'restart'} is interpreted to mean you wish the
39+
%% child to be restarted according to the delay parameters, but
40+
%% gen_server will not log the error. Thus from gen_server's
41+
%% perspective it's a normal exit, whilst from supervisor's
42+
%% perspective, it's an abnormal exit.
43+
%%
3444
%% 4) Added an 'intrinsic' restart type. Like the transient type, this
3545
%% type means the child should only be restarted if the child exits
3646
%% abnormally. Unlike the transient type, if the child exits
@@ -536,6 +546,9 @@ do_restart(permanent, Reason, Child, State) ->
536546
restart(Child, State);
537547
do_restart(Type, normal, Child, State) ->
538548
del_child_and_maybe_shutdown(Type, Child, State);
549+
do_restart({RestartType, Delay}, {shutdown, restart} = Reason, Child, State)
550+
when RestartType =:= transient orelse RestartType =:= intrinsic ->
551+
do_restart_delay({RestartType, Delay}, Reason, Child, State);
539552
do_restart(Type, {shutdown, _}, Child, State) ->
540553
del_child_and_maybe_shutdown(Type, Child, State);
541554
do_restart(Type, shutdown, Child = #child{child_type = supervisor}, State) ->

0 commit comments

Comments
 (0)