Skip to content
This repository was archived by the owner on Nov 16, 2020. It is now read-only.

Commit d3f8531

Browse files
Make rabbit_shovel_dyn_worker_sup_sup:start_link/0 idempotent
This allows for a very rudimentary way of restarting a Shovel: stopping it with stop_child/2 and starting all of them using the otherwise idempotent start_link/0. References #48.
1 parent 856de5f commit d3f8531

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/rabbit_shovel_dyn_worker_sup_sup.erl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@
2626
-define(SUPERVISOR, ?MODULE).
2727

2828
start_link() ->
29-
{ok, Pid} = mirrored_supervisor:start_link(
29+
Pid = case mirrored_supervisor:start_link(
3030
{local, ?SUPERVISOR}, ?SUPERVISOR,
31-
fun rabbit_misc:execute_mnesia_transaction/1, ?MODULE, []),
31+
fun rabbit_misc:execute_mnesia_transaction/1, ?MODULE, []) of
32+
{ok, Pid0} -> Pid0;
33+
{error, {already_started, Pid0}} -> Pid0
34+
end,
3235
Shovels = rabbit_runtime_parameters:list_component(<<"shovel">>),
3336
[start_child({pget(vhost, Shovel), pget(name, Shovel)},
3437
pget(value, Shovel)) || Shovel <- Shovels],

0 commit comments

Comments
 (0)