Commits

Anonymous committed 276d537

router start/stop

Comments (0)

Files changed (1)

src/emongo_sup.erl

 
 -export([start_link/0, start_pool/5, stop_pool/1, pools/0, worker_pid/1]).
 -export([start_balancer/2, stop_balancer/1]).
+-export([start_router/2, stop_router/1]).
 
 %% supervisor exports
 -export([init/1]).
 
 start_link() -> supervisor:start_link({local, ?MODULE}, ?MODULE, []).
 
+start_router(BalId, Pools) ->
+    supervisor:start_child(?MODULE,
+                           {BalId,
+                            {emongo_router, start_link, [BalId, Pools]},
+                            permanent, 10000, worker, [emongo_router]
+                           }).
+
+stop_router(BalId) ->
+    case [Pid || {PoolId, Pid, _, [emongo_router]} <- supervisor:which_children(?MODULE), PoolId =:= BalId] of
+        [Pid] ->
+            gen_server:call(Pid, stop_children),
+            stop_pool(BalId)
+    end.
+
+
 start_balancer(BalId, Pools) ->
     supervisor:start_child(?MODULE,
                            {BalId,