anchor.diff:                  ?error("[CouchBase Gateway ~p] Unable to communicate with port due to: ~p", [ID, Reason]),
                   State#{status => failed};
               restart when CT > MinRestartTime ->
  +                ?info("[CouchBase Gateway ~p] Restart request...", [ID]),
                   State#{status => restarting};
               restart ->
                   State;
               {'DOWN', _, process, Parent, Reason} ->
  -                catch port_close(PortFD),
  +                    catch port_close(PortFD),
                   State#{status => closed};
               stop ->
  -                catch port_close(PortFD),
  +                    catch port_close(PortFD),
                   State#{status => closed};
               Other ->
                   ?warning("[CouchBase Gateway ~p] ~p", [ID, Other]),
  
positive.code:         {error, econnrefused} when Retry > 0 ->
              ?info("Unable to connect to ~p", [DB]),
              ServerPid ! restart,
              db_run(Mod, Fun, Args, Retry - 1);
          Other -> Other
      end.
  
  
  
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  
negative.code: %%--------------------------------------------------------------------
  -spec start_gateway(Parent :: pid(), N :: non_neg_integer(), Hostname :: binary(), Port :: non_neg_integer()) -> no_return().
  start_gateway(Parent, N, Hostname, Port) ->
      GWPort = crypto:rand_uniform(?GATEWAY_BASE_PORT_MIN, ?GATEWAY_BASE_PORT_MAX),
      GWAdminPort = GWPort + 1000,
      ?info("Statring couchbase gateway #~p: localhost:~p => ~p:~p", [N, GWPort, Hostname, Port]),
  
  