diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2014-06-06 17:28:45 +0100 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2014-06-06 17:28:45 +0100 |
commit | cd35bd0a344ea92d52110ef14c5120f0a808b152 (patch) | |
tree | 9cba071f97d44cbc3c4c11d8e4ea4bbdc87f4a87 | |
parent | 2c61b5fa51ea72915471bc8f6c73be75c48d8f1d (diff) | |
download | rabbitmq-server-cd35bd0a344ea92d52110ef14c5120f0a808b152.tar.gz |
Move the code-unloading thing to rabbit_plugins, and remove the unpacked plugin after doing it, so that it actually allows us to reload modified plugins.
-rw-r--r-- | src/rabbit.erl | 12 | ||||
-rw-r--r-- | src/rabbit_plugins.erl | 15 |
2 files changed, 15 insertions, 12 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl index 9f78a58a..90181619 100644 --- a/src/rabbit.erl +++ b/src/rabbit.erl @@ -395,20 +395,8 @@ stop_apps(Apps) -> false -> run_cleanup_steps(Apps); %% plugin deactivation true -> ok %% it's all going anyway end, - unload_apps(Apps), ok. -unload_apps(Apps) -> - [begin - {ok, Mods} = application:get_key(App, modules), - [begin - code:soft_purge(Mod), - code:delete(Mod), - false = code:is_loaded(Mod) - end || Mod <- Mods], - application:unload(App) - end || App <- Apps]. - handle_app_error(Term) -> fun(App, {bad_return, {_MFA, {'EXIT', {ExitReason, _}}}}) -> throw({Term, App, ExitReason}); diff --git a/src/rabbit_plugins.erl b/src/rabbit_plugins.erl index e139eed4..0eabf4dd 100644 --- a/src/rabbit_plugins.erl +++ b/src/rabbit_plugins.erl @@ -49,6 +49,7 @@ ensure(Wanted) -> {disabled, Stop}]), rabbit:start_apps(Start), rabbit:stop_apps(Stop), + clean_plugins(Stop), {ok, Start, Stop}. %% @doc Prepares the file system and installs all enabled plugins. @@ -153,6 +154,20 @@ prepare_plugins(Enabled) -> [prepare_dir_plugin(PluginAppDescPath) || PluginAppDescPath <- filelib:wildcard(ExpandDir ++ "/*/ebin/*.app")]. +clean_plugins(Plugins) -> + {ok, ExpandDir} = application:get_env(rabbit, plugins_expand_dir), + [clean_plugin(Plugin, ExpandDir) || Plugin <- Plugins]. + +clean_plugin(Plugin, ExpandDir) -> + {ok, Mods} = application:get_key(Plugin, modules), + application:unload(Plugin), + [begin + code:soft_purge(Mod), + code:delete(Mod), + false = code:is_loaded(Mod) + end || Mod <- Mods], + delete_recursively(rabbit_misc:format("~s/~s", [ExpandDir, Plugin])). + prepare_dir_plugin(PluginAppDescPath) -> code:add_path(filename:dirname(PluginAppDescPath)), list_to_atom(filename:basename(PluginAppDescPath, ".app")). |