From e22f30f671398b48b0cb5265f2323b11bfae1e6e Mon Sep 17 00:00:00 2001 From: Ben Hood <0x6e6562@gmail.com> Date: Wed, 15 Jul 2009 14:39:33 +0100 Subject: Added a single shot function that can be specified in an OTP app descriptor that doesn't otherwise need to run a process --- src/rabbit_plugin.erl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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), -- cgit v1.2.1