summaryrefslogtreecommitdiff
path: root/src/rabbit_amqqueue_sup.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/rabbit_amqqueue_sup.erl')
-rw-r--r--src/rabbit_amqqueue_sup.erl34
1 files changed, 16 insertions, 18 deletions
diff --git a/src/rabbit_amqqueue_sup.erl b/src/rabbit_amqqueue_sup.erl
index 0fd64c26..465c0412 100644
--- a/src/rabbit_amqqueue_sup.erl
+++ b/src/rabbit_amqqueue_sup.erl
@@ -18,35 +18,33 @@
-behaviour(supervisor2).
--export([start_link/0, start_child/2]).
+-export([start_link/2]).
-export([init/1]).
-include("rabbit.hrl").
--define(SERVER, ?MODULE).
-
%%----------------------------------------------------------------------------
-ifdef(use_specs).
--spec(start_link/0 :: () -> rabbit_types:ok_pid_or_error()).
--spec(start_child/2 ::
- (node(), [any()]) -> rabbit_types:ok(pid() | undefined) |
- rabbit_types:ok({pid(), any()}) |
- rabbit_types:error(any())).
+-spec(start_link/2 :: (rabbit_types:amqqueue(), rabbit_prequeue:start_mode()) ->
+ {'ok', pid(), pid()}).
-endif.
%%----------------------------------------------------------------------------
-start_link() ->
- supervisor2:start_link({local, ?SERVER}, ?MODULE, []).
-
-start_child(Node, Args) ->
- supervisor2:start_child({?SERVER, Node}, Args).
-
-init([]) ->
- {ok, {{simple_one_for_one, 10, 10},
- [{rabbit_amqqueue, {rabbit_amqqueue_process, start_link, []},
- temporary, ?MAX_WAIT, worker, [rabbit_amqqueue_process]}]}}.
+start_link(Q, StartMode) ->
+ Marker = spawn_link(fun() -> receive stop -> ok end end),
+ ChildSpec = {rabbit_amqqueue,
+ {rabbit_prequeue, start_link, [Q, StartMode, Marker]},
+ intrinsic, ?MAX_WAIT, worker, [rabbit_amqqueue_process,
+ rabbit_mirror_queue_slave]},
+ {ok, SupPid} = supervisor2:start_link(?MODULE, []),
+ {ok, QPid} = supervisor2:start_child(SupPid, ChildSpec),
+ unlink(Marker),
+ Marker ! stop,
+ {ok, SupPid, QPid}.
+
+init([]) -> {ok, {{one_for_one, 5, 10}, []}}.