Skip to content

Commit da3acdd

Browse files
author
Simon MacMullen
committed
Merge bug24377
2 parents 9dc1ad0 + 8aa5c1f commit da3acdd

File tree

4 files changed

+16
-17
lines changed

4 files changed

+16
-17
lines changed

src/rabbit.erl

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919
-behaviour(application).
2020

21-
-export([prepare/0, start/0, stop/0, stop_and_halt/0, status/0, environment/0,
21+
-export([prepare/0, start/0, stop/0, stop_and_halt/0, status/0,
22+
is_running/0 , is_running/1, environment/0,
2223
rotate_logs/1, force_event_refresh/0]).
2324

2425
-export([start/2, stop/1]).
@@ -196,6 +197,8 @@
196197
{os, {atom(), atom()}} |
197198
{erlang_version, string()} |
198199
{memory, any()}]).
200+
-spec(is_running/0 :: () -> boolean()).
201+
-spec(is_running/1 :: (node()) -> boolean()).
199202
-spec(environment/0 :: () -> [{atom() | term()}]).
200203
-spec(log_location/1 :: ('sasl' | 'kernel') -> log_location()).
201204

@@ -233,11 +236,19 @@ stop_and_halt() ->
233236

234237
status() ->
235238
[{pid, list_to_integer(os:getpid())},
236-
{running_applications, application:which_applications()},
239+
{running_applications, application:which_applications(infinity)},
237240
{os, os:type()},
238241
{erlang_version, erlang:system_info(system_version)},
239242
{memory, erlang:memory()}].
240243

244+
is_running() -> is_running(node()).
245+
246+
is_running(Node) ->
247+
case rpc:call(Node, application, which_applications, [infinity]) of
248+
{badrpc, _} -> false;
249+
Apps -> proplists:is_defined(rabbit, Apps)
250+
end.
251+
241252
environment() ->
242253
lists:keysort(
243254
1, [P || P = {K, _} <- application:get_all_env(rabbit),

src/rabbit_control.erl

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ wait_for_application(Node, PidFile, Inform) ->
360360

361361
wait_for_application(Node, Pid) ->
362362
case process_up(Pid) of
363-
true -> case node_up(Node) of
363+
true -> case rabbit:is_running(Node) of
364364
true -> ok;
365365
false -> timer:sleep(1000),
366366
wait_for_application(Node, Pid)
@@ -376,12 +376,6 @@ wait_and_read_pid_file(PidFile) ->
376376
{error, _} = E -> exit({error, {could_not_read_pid, E}})
377377
end.
378378

379-
node_up(Node) ->
380-
case rpc_call(Node, application, which_applications, [infinity]) of
381-
{badrpc, _} -> false;
382-
Apps -> proplists:is_defined(rabbit, Apps)
383-
end.
384-
385379
% Test using some OS clunkiness since we shouldn't trust
386380
% rpc:call(os, getpid, []) at this point
387381
process_up(Pid) ->

src/rabbit_direct.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ list() ->
7272
%%----------------------------------------------------------------------------
7373

7474
connect(Username, VHost, Protocol, Pid, Infos) ->
75-
case lists:keymember(rabbit, 1, application:which_applications()) of
75+
case rabbit:is_running() of
7676
true ->
7777
case rabbit_access_control:check_user_login(Username, []) of
7878
{ok, User} ->

src/rabbit_upgrade.erl

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,13 +228,7 @@ secondary_upgrade(AllNodes) ->
228228
ok.
229229

230230
nodes_running(Nodes) ->
231-
[N || N <- Nodes, node_running(N)].
232-
233-
node_running(Node) ->
234-
case rpc:call(Node, application, which_applications, []) of
235-
{badrpc, _} -> false;
236-
Apps -> lists:keysearch(rabbit, 1, Apps) =/= false
237-
end.
231+
[N || N <- Nodes, rabbit:is_running(N)].
238232

239233
%% -------------------------------------------------------------------
240234

0 commit comments

Comments
 (0)