summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Watson <watson.timothy@gmail.com>2013-12-16 16:06:12 +0000
committerTim Watson <watson.timothy@gmail.com>2013-12-16 16:06:12 +0000
commit8b397e93f589e6c57182b76e941cc02274656885 (patch)
treed32f6b3468f6ba547416c486f210a3a82d94747b
parent49c99e6e683dc312a30c9997196c458a1a637d3b (diff)
downloadrabbitmq-server-git-8b397e93f589e6c57182b76e941cc02274656885.tar.gz
Tidy/Refactor boot step handling
Simplify the boot step loading/application code and switch from using a discrete rabbit_cleanup_step module attribute; We now search the regular boot steps directly for ‘cleanup’ entries.
-rw-r--r--src/rabbit_boot.erl29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/rabbit_boot.erl b/src/rabbit_boot.erl
index 3f0ceea65e..29abaefee5 100644
--- a/src/rabbit_boot.erl
+++ b/src/rabbit_boot.erl
@@ -125,7 +125,7 @@ stop(Apps) ->
TargetApps, handle_app_error(error_during_shutdown))
after
try
- BootSteps = load_steps(rabbit_boot_step),
+ BootSteps = load_steps(),
ToDelete = [Step || {App, _, _}=Step <- BootSteps,
lists:member(App, TargetApps)],
[ets:delete(?MODULE, Step) || {_, Step, _} <- ToDelete],
@@ -150,22 +150,21 @@ run_cleanup_steps(Apps) ->
fun({_, Name, _}=Step, Acc) ->
case sets:is_element(Name, Completed) of
true -> Acc;
- false -> run_boot_step(Step, rabbit_cleanup_step),
+ false -> run_cleanup_step(Step),
sets:add_element(Name, Acc)
end
end,
Completed,
- [Step || {App, _, _}=Step <- load_steps(rabbit_cleanup_step),
- lists:member(App, Apps)]),
+ [Step || {App, _, _}=Step <- load_steps(), lists:member(App, Apps)]),
ok.
run_boot_steps() ->
- Steps = load_steps(rabbit_boot_step),
- [ok = run_boot_step(Step, rabbit_boot_step) || Step <- Steps],
+ Steps = load_steps(),
+ [ok = run_boot_step(Step) || Step <- Steps],
ok.
-load_steps(StepType) ->
- StepAttrs = rabbit_misc:all_app_module_attributes(StepType),
+load_steps() ->
+ StepAttrs = rabbit_misc:all_app_module_attributes(rabbit_boot_step),
sort_boot_steps(
lists:usort(
[{Mod, {AppName, Steps}} || {AppName, Mod, Steps} <- StepAttrs])).
@@ -280,18 +279,20 @@ handle_app_error(Term) ->
throw({Term, App, Reason})
end.
-run_boot_step({_, _, Attributes}, rabbit_cleanup_step) ->
- run_step(Attributes);
-run_boot_step({_, StepName, Attributes}, rabbit_boot_step) ->
+run_cleanup_step({_, _, Attributes}) ->
+ run_step_name(Attributes, cleanup).
+
+run_boot_step({_, StepName, Attributes}) ->
case catch already_run(StepName) of
- false -> ok = run_step(Attributes),
+ false -> ok = run_step_name(Attributes, mfa),
mark_complete(StepName);
true -> ok
end,
ok.
-run_step(Attributes) ->
- case [MFA || {mfa, MFA} <- Attributes] of
+run_step_name(Attributes, AttributeName) ->
+ case [MFA || {Key, MFA} <- Attributes,
+ Key =:= AttributeName] of
[] ->
ok;
MFAs ->