15
15
% %
16
16
-module (app_utils ).
17
17
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 ,
19
20
stop_applications /1 , stop_applications /2 , app_dependency_order /2 ,
20
21
app_dependencies /1 ]).
21
22
@@ -49,8 +50,11 @@ stop_applications(Apps) ->
49
50
end ).
50
51
51
52
start_applications (Apps , ErrorHandler ) ->
53
+ start_applications (Apps , ErrorHandler , #{}).
54
+
55
+ start_applications (Apps , ErrorHandler , AppModes ) ->
52
56
manage_applications (fun lists :foldl /3 ,
53
- fun start / 1 ,
57
+ fun ( App ) -> start ( App , AppModes ) end ,
54
58
fun application :stop /1 ,
55
59
already_started ,
56
60
ErrorHandler ,
@@ -62,7 +66,7 @@ stop_applications(Apps, ErrorHandler) ->
62
66
rabbit_log :info (" Stopping application '~s '" , [App ]),
63
67
application :stop (App )
64
68
end ,
65
- fun start / 1 ,
69
+ fun ( App ) -> start ( App , #{}) end ,
66
70
not_started ,
67
71
ErrorHandler ,
68
72
Apps ).
@@ -124,15 +128,11 @@ manage_applications(Iterate, Do, Undo, SkipError, ErrorHandler, Apps) ->
124
128
end , [], Apps ),
125
129
ok .
126
130
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