Skip to content
This repository was archived by the owner on Nov 17, 2020. It is now read-only.

Commit dd45d64

Browse files
author
Daniil Fedotov
committed
API to start applications in different modes
1 parent d735a46 commit dd45d64

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/app_utils.erl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
%%
1616
-module(app_utils).
1717

18-
-export([load_applications/1, start_applications/1, start_applications/2,
18+
-export([load_applications/1,
19+
start_applications/1, start_applications/2, start_applications/3,
1920
stop_applications/1, stop_applications/2, app_dependency_order/2,
2021
app_dependencies/1]).
2122

@@ -49,8 +50,11 @@ stop_applications(Apps) ->
4950
end).
5051

5152
start_applications(Apps, ErrorHandler) ->
53+
start_applications(Apps, ErrorHandler, #{}).
54+
55+
start_applications(Apps, ErrorHandler, AppModes) ->
5256
manage_applications(fun lists:foldl/3,
53-
fun start/1,
57+
fun(App) -> start(App, AppModes) end,
5458
fun application:stop/1,
5559
already_started,
5660
ErrorHandler,
@@ -62,7 +66,7 @@ stop_applications(Apps, ErrorHandler) ->
6266
rabbit_log:info("Stopping application '~s'", [App]),
6367
application:stop(App)
6468
end,
65-
fun start/1,
69+
fun(App) -> start(App, #{}) end,
6670
not_started,
6771
ErrorHandler,
6872
Apps).
@@ -124,15 +128,11 @@ manage_applications(Iterate, Do, Undo, SkipError, ErrorHandler, Apps) ->
124128
end, [], Apps),
125129
ok.
126130

127-
-ifdef(TEST).
128-
-define(APP_MODE, transient).
129-
-else.
130-
-define(APP_MODE, temporary).
131-
-endif.
132-
133-
start(rabbit) ->
134-
%% Stops the Erlang VM when the rabbit application stops abnormally
135-
%% i.e. message store reaches its restart limit
136-
application:start(rabbit, ?APP_MODE);
137-
start(App) ->
138-
application:start(App).
131+
start(App, Modes) ->
132+
Mode = maps:get(App, Modes, default_mode(App)),
133+
application:start(App, Mode).
134+
135+
%% Stops the Erlang VM when the rabbit application stops abnormally
136+
%% i.e. message store reaches its restart limit
137+
default_mode(rabbit) -> transient;
138+
default_mode(_) -> temporary.

0 commit comments

Comments
 (0)