Skip to content

Commit 1861006

Browse files
author
Simon MacMullen
committed
Do nothing if the rabbit application is already running. Similarly, don't explode if the boot marker is there, just do nothing.
1 parent 9b8cf84 commit 1861006

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

src/rabbit.erl

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -347,19 +347,25 @@ handle_app_error(App, Reason) ->
347347

348348
start_it(StartFun) ->
349349
Marker = spawn_link(fun() -> receive stop -> ok end end),
350-
register(rabbit_boot, Marker),
351-
try
352-
StartFun()
353-
catch
354-
throw:{could_not_start, _App, _Reason}=Err ->
355-
boot_error(Err, not_available);
356-
_:Reason ->
357-
boot_error(Reason, erlang:get_stacktrace())
358-
after
359-
unlink(Marker),
360-
Marker ! stop,
361-
%% give the error loggers some time to catch up
362-
timer:sleep(100)
350+
case catch register(rabbit_boot, Marker) of
351+
true -> try
352+
case is_running() of
353+
true -> ok;
354+
false -> StartFun()
355+
end
356+
catch
357+
throw:{could_not_start, _App, _Reason}=Err ->
358+
boot_error(Err, not_available);
359+
_:Reason ->
360+
boot_error(Reason, erlang:get_stacktrace())
361+
after
362+
unlink(Marker),
363+
Marker ! stop,
364+
%% give the error loggers some time to catch up
365+
timer:sleep(100)
366+
end;
367+
_ -> unlink(Marker),
368+
Marker ! stop
363369
end.
364370

365371
stop() ->

0 commit comments

Comments
 (0)