summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Hood <0x6e6562@gmail.com>2009-07-15 14:39:33 +0100
committerBen Hood <0x6e6562@gmail.com>2009-07-15 14:39:33 +0100
commite22f30f671398b48b0cb5265f2323b11bfae1e6e (patch)
tree1905edd364a2888c648daff59513503f68d1b62f
parent29f990714ff80995c52aa5492b2235dd71d39955 (diff)
downloadrabbitmq-server-bug21140.tar.gz
Added a single shot function that can be specified in an OTP app descriptor that doesn't otherwise need to run a processbug21140
-rw-r--r--src/rabbit_plugin.erl14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/rabbit_plugin.erl b/src/rabbit_plugin.erl
index ede7abcf..3064817f 100644
--- a/src/rabbit_plugin.erl
+++ b/src/rabbit_plugin.erl
@@ -74,7 +74,19 @@ ensure_dependencies(Plugin) when is_atom(Plugin)->
[case lists:member(App, Running) of
true -> ok;
false -> application:start(App)
- end || App <- Required].
+ end || App <- Required],
+ run_one_shot(Plugin).
+
+%% This allows an OTP to run a single shot function that it
+%% specifies in it's descriptor without having to run a process
+run_one_shot(Plugin) ->
+ case application:get_env(Plugin, one_shot) of
+ {ok, {M,F,A}} -> M:F(A);
+ undefined -> ok;
+ X ->
+ rabbit_log:error("Error loading one shot for ~p plugin: "
+ "~p~n", [Plugin, X])
+ end.
parse_plugin_config(Plugin) when is_list(Plugin)->
Atom = list_to_atom(Plugin),