diff options
| author | Tim Watson <tim@rabbitmq.com> | 2014-03-04 12:15:35 +0000 |
|---|---|---|
| committer | Tim Watson <tim@rabbitmq.com> | 2014-03-04 12:15:35 +0000 |
| commit | bb17a6e526b7bc179d22483e9b436b4a79e5dda4 (patch) | |
| tree | b4e1fc27bf75b2d1264fbabb0925276818777fc1 | |
| parent | f0ecdaaf4876ff78fa1d99725d9de5193331c8ee (diff) | |
| download | rabbitmq-server-git-bb17a6e526b7bc179d22483e9b436b4a79e5dda4.tar.gz | |
Inline some more and get closer still to default
| -rw-r--r-- | src/rabbit.erl | 24 | ||||
| -rw-r--r-- | src/rabbit_boot.erl | 24 | ||||
| -rw-r--r-- | src/rabbit_plugins.erl | 2 |
3 files changed, 26 insertions, 24 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl index 2070713e0e..9644f75eb1 100644 --- a/src/rabbit.erl +++ b/src/rabbit.erl @@ -24,7 +24,7 @@ start_fhc/0]). -export([run_boot_steps/0, load_steps/1, run_step/3]). -export([start/2, stop/1]). - +-export([handle_app_error/1, start_apps/1]). -export([log_location/1]). %% for testing %%--------------------------------------------------------------------------- @@ -242,6 +242,7 @@ -spec(maybe_insert_default_data/0 :: () -> 'ok'). -spec(boot_delegate/0 :: () -> 'ok'). -spec(recover/0 :: () -> 'ok'). +-spec(handle_app_error/1 :: (term()) -> fun((atom(), term()) -> no_return())). -endif. @@ -312,7 +313,7 @@ start() -> ok = ensure_working_log_handlers(), rabbit_node_monitor:prepare_cluster_status_files(), rabbit_mnesia:check_cluster_consistency(), - ok = rabbit_boot:start(app_startup_order()), + ok = start_apps(app_startup_order()), ok = log_broker_started(rabbit_plugins:active()) end). @@ -330,10 +331,27 @@ boot() -> rabbit_mnesia:check_cluster_consistency(), Plugins = rabbit_plugins:setup(), ToBeLoaded = Plugins ++ ?APPS, - ok = rabbit_boot:start(ToBeLoaded), + ok = start_apps(ToBeLoaded), ok = log_broker_started(Plugins) end). +handle_app_error(Term) -> + fun(App, {bad_return, {_MFA, {'EXIT', {ExitReason, _}}}}) -> + throw({Term, App, ExitReason}); + (App, Reason) -> + throw({Term, App, Reason}) + end. + +start_apps(Apps) -> + rabbit_boot:force_reload(Apps), + StartupApps = app_utils:app_dependency_order(Apps, false), + case whereis(?MODULE) of + undefined -> rabbit:run_boot_steps(); + _ -> ok + end, + ok = app_utils:start_applications(StartupApps, + handle_app_error(could_not_start)). + start_it(StartFun) -> Marker = spawn_link(fun() -> receive stop -> ok end end), case catch register(rabbit_boot, Marker) of diff --git a/src/rabbit_boot.erl b/src/rabbit_boot.erl index 0b7b71a324..e9bf5457de 100644 --- a/src/rabbit_boot.erl +++ b/src/rabbit_boot.erl @@ -17,7 +17,8 @@ -module(rabbit_boot). -export([prepare_boot_table/0]). --export([start/1, stop/1]). +-export([stop/1]). +-export([force_reload/1]). -export([already_run/1, mark_complete/1]). -ifdef(use_specs). @@ -25,8 +26,8 @@ -spec(prepare_boot_table/0 :: () -> 'ok'). -spec(already_run/1 :: (atom()) -> boolean()). -spec(mark_complete/1 :: (atom()) -> 'ok'). --spec(start/1 :: ([atom()]) -> 'ok'). -spec(stop/1 :: ([atom()]) -> 'ok'). +-spec(force_reload/1 :: ([atom()]) -> 'ok'). -endif. @@ -49,20 +50,10 @@ prepare_boot_table() -> ets:new(?MODULE, [named_table, public, ordered_set]). -start(Apps) -> - force_reload(Apps), - StartupApps = app_utils:app_dependency_order(Apps, false), - case whereis(?MODULE) of - undefined -> rabbit:run_boot_steps(); - _ -> ok - end, - ok = app_utils:start_applications(StartupApps, - handle_app_error(could_not_start)). - stop(Apps) -> try ok = app_utils:stop_applications( - Apps, handle_app_error(error_during_shutdown)) + Apps, rabbit:handle_app_error(error_during_shutdown)) after BootSteps = rabbit:load_steps(boot), ToDelete = [Step || {App, _, _}=Step <- BootSteps, @@ -125,13 +116,6 @@ load_mod(Mod) -> _ -> code:load_file(Mod) end. -handle_app_error(Term) -> - fun(App, {bad_return, {_MFA, {'EXIT', {ExitReason, _}}}}) -> - throw({Term, App, ExitReason}); - (App, Reason) -> - throw({Term, App, Reason}) - end. - run_cleanup_step({_, StepName, Attributes}) -> rabbit:run_step(StepName, Attributes, cleanup). diff --git a/src/rabbit_plugins.erl b/src/rabbit_plugins.erl index add818e375..e15ae0b182 100644 --- a/src/rabbit_plugins.erl +++ b/src/rabbit_plugins.erl @@ -41,7 +41,7 @@ enable(Enabled) -> prepare_plugins(Enabled), app_utils:update_running_apps( - fun() -> rabbit_boot:start(Enabled) end, + fun() -> rabbit:start_apps(Enabled) end, fun(Diff) -> ok = rabbit_event:notify(plugins_changed, [{enabled, Diff}]) end). |
