This commit is contained in:
付强 2019-08-04 19:03:05 +08:00 committed by Shawn
parent 253ffcdb5e
commit 111380bf25
1 changed files with 3 additions and 1 deletions

View File

@ -137,9 +137,11 @@ handle_info(reconnect, State = #state{opts = Opts, on_reconnect = OnReconnect})
case catch connect(State) of
{ok, Client} ->
handle_reconnect(Client, OnReconnect),
{noreply, State#state{client = Client}};
erlang:link(Client),
{noreply, State#state{client = Client, supervisees = [Client]}};
{{ok, Client}, #{supervisees := SupPids} = _SupOpts} ->
handle_reconnect(Client, OnReconnect),
[erlang:link(P) || P <- SupPids],
{noreply, State#state{client = Client, supervisees = SupPids}};
{Err, _Reason} when Err =:= error orelse Err =:= 'EXIT' ->
reconnect(proplists:get_value(auto_reconnect, Opts), State)