From 35b76af72622664b6d59f41e34811934e181ebc2 Mon Sep 17 00:00:00 2001 From: Matthew Sackman Date: Tue, 28 Jun 2011 16:37:26 +0100 Subject: 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. --- src/rabbit.erl | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) 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 -- cgit v1.2.1