Commits

Anonymous committed 7dee38c

connect router to existing pools (in case of restart)
router polling time not equal pool's

  • Participants
  • Parent commits 3afe931

Comments (0)

Files changed (1)

File src/emongo_router.erl

                }).
 
 -define(POOL_ID(BalancerId, PoolIdx), {BalancerId, PoolIdx}).
--define(RECHECK_TIME, 10000).
+-define(RECHECK_TIME, 9500).
 
 %%====================================================================
 %% API
     gen_server:start_link(?MODULE, [BalId, Pools], []).
 
 pid(BalancerPid) ->
-    gen_server:call(BalancerPid, pid, infinity).
+    gen_server:call(BalancerPid, pid).
 
 %%====================================================================
 %% gen_server callbacks
 %% Description: Initiates the server
 %%--------------------------------------------------------------------
 init([BalId, Pools]) ->
-    process_flag(trap_exit, true),
     self() ! {init, Pools},
     {ok, #state{id = BalId,
                 active = [],
     Fun = fun({Host, Port, Database, Size}, {PoolIdx, PoolList}) ->
                   case emongo_sup:start_pool(?POOL_ID(BalId, PoolIdx),
                                              Host, Port, Database, Size) of
-                      {ok, PoolPid} ->
-                          link(PoolPid),
-                          {PoolIdx + 1, [PoolIdx | PoolList]};
-                      _ ->
-                          {PoolIdx + 1, PoolList}
-                  end
+                      {ok, _} ->
+                          ok;
+                      {error, {already_started, _}} ->
+                          ok
+                  end,
+                  {PoolIdx + 1, [PoolIdx | PoolList]}
           end,
     {_, PoolList} = lists:foldl(Fun, {1, Active}, Pools),
     {noreply, State#state{active=lists:sort(PoolList)}};