aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/kernel/src/application.erl23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/kernel/src/application.erl b/lib/kernel/src/application.erl
index 6efc1b4499..5dd6b73857 100644
--- a/lib/kernel/src/application.erl
+++ b/lib/kernel/src/application.erl
@@ -22,6 +22,7 @@
load/1, load/2, unload/1, takeover/2,
which_applications/0, which_applications/1,
loaded_applications/0, permit/2]).
+-export([ensure_started/1, ensure_started/2]).
-export([set_env/3, set_env/4, unset_env/2, unset_env/3]).
-export([get_env/1, get_env/2, get_env/3, get_all_env/0, get_all_env/1]).
-export([get_key/1, get_key/2, get_all_key/0, get_all_key/1]).
@@ -135,6 +136,28 @@ start(Application, RestartType) ->
Error
end.
+-spec ensure_started(Application) -> 'ok' | {'error', Reason} when
+ Application :: atom(),
+ Reason :: term().
+
+ensure_started(Application) ->
+ ensure_started(Application, temporary).
+
+-spec ensure_started(Application, Type) -> 'ok' | {'error', Reason} when
+ Application :: atom(),
+ Type :: restart_type(),
+ Reason :: term().
+
+ensure_started(Application, RestartType) ->
+ case start(Application, RestartType) of
+ ok ->
+ ok;
+ {error, {already_started, Application}} ->
+ ok;
+ Error ->
+ Error
+ end.
+
-spec start_boot(Application :: atom()) -> 'ok' | {'error', term()}.
start_boot(Application) ->