summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@rabbitmq.com>2011-06-28 16:37:26 +0100
committerMatthew Sackman <matthew@rabbitmq.com>2011-06-28 16:37:26 +0100
commit35b76af72622664b6d59f41e34811934e181ebc2 (patch)
tree42c18e8eae9e38bb9d5ff9e117f8da36cf2bd30a
parente7ec913d9c76db773b5a548e8dac3dbc35cbeb70 (diff)
downloadrabbitmq-server-35b76af72622664b6d59f41e34811934e181ebc2.tar.gz
There's a possibility that rabbit has to be able to be started without being booted. Thus we need to be able to load the transitive closure of rabbit's dependencies on demand. This is especially needed for the tests.
-rw-r--r--src/rabbit.erl25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl
index 0d163944..5ec0611a 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -390,7 +390,32 @@ config_files() ->
%%---------------------------------------------------------------------------
+load_applications() ->
+ load_applications(queue:from_list(?APPS), sets:new()).
+
+load_applications(Worklist, Loaded) ->
+ case queue:out(Worklist) of
+ {empty, _WorkList} ->
+ ok;
+ {{value, App}, Worklist1} ->
+ case sets:is_element(App, Loaded) of
+ true -> load_applications(Worklist1, Loaded);
+ false -> case application:load(App) of
+ ok -> ok;
+ {error, {already_loaded, App}} -> ok;
+ Error -> throw(Error)
+ end,
+ load_applications(
+ case application:get_key(App, applications) of
+ undefined -> Worklist1;
+ {ok, Lst} -> queue:join(Worklist1,
+ queue:from_list(Lst))
+ end, sets:add_element(App, Loaded))
+ end
+ end.
+
application_load_order() ->
+ ok = load_applications(),
{ok, G} = rabbit_misc:build_acyclic_graph(
fun application_graph_vertex/2, fun application_graph_edge/2,
[{App, case application:get_key(App, applications) of