diff options
author | Ben Hood <0x6e6562@gmail.com> | 2009-07-08 15:27:38 +0100 |
---|---|---|
committer | Ben Hood <0x6e6562@gmail.com> | 2009-07-08 15:27:38 +0100 |
commit | 19f4f09891b2d2982d8754a031f142ee057bce5f (patch) | |
tree | b201582710b3857d9e88ba513cd0d60946702e7e | |
parent | e8ffd72ed4432583bf5294465766fe52534dced2 (diff) | |
download | rabbitmq-server-19f4f09891b2d2982d8754a031f142ee057bce5f.tar.gz |
Library loading can traverse subdirs to load the binaries they need
-rw-r--r-- | src/rabbit.erl | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl index 3576c435..56db74d5 100644 --- a/src/rabbit.erl +++ b/src/rabbit.erl @@ -301,17 +301,34 @@ start_plugins() -> LibDir = PluginsDir ++ "/lib", case filelib:is_dir(LibDir) of false -> ok; - true -> true = code:add_path(LibDir) + true -> + % TODO: Refactor the commonality + [begin + [WithoutExtension|_] = string:tokens(Path, "."), + io:format("Loading ~p~n",[WithoutExtension]), + {module,_} = code:load_abs(WithoutExtension) + end || Path <- filelib:wildcard(LibDir ++ "/*/ebin/*.beam")] end, [begin - [Dir,Plugin,Ebin,Mod|_] = string:tokens(PluginApp,"/."), + [Dir,Plugin,Ebin,Mod|_] = string:tokens(Config,"/."), true = code:add_path(Dir ++ "/" ++ Plugin ++ "/" ++ Ebin), %% TODO: Might want a separate supervisor - start_child(list_to_atom(Mod)) - end || PluginApp <- filelib:wildcard("plugins/*/ebin/*.app")], + %start_child(list_to_atom(Mod)) + {Name, Fun} = parse_plugin_config(Config), + %Fun(), + io:format("Started ~n plugin ~p", [Name]) + end || Config <- filelib:wildcard("plugins/*/ebin/*.plugin")], ok end. +parse_plugin_config(File) -> + case file:consult(File) of + {ok, [{plugin, Name, [{startup_function, {M, F, A}}, {env, Env}]}]} -> + {Name, M:F(A)}; + _ -> + error + end. + rotate_logs(File, Suffix, Handler) -> rotate_logs(File, Suffix, Handler, Handler). |