From 45a8f39ef1ade82a379b8a94ff3378d0b149bd96 Mon Sep 17 00:00:00 2001 From: Fred Hebert Date: Thu, 20 Jun 2013 13:56:56 -0400 Subject: Add application:ensure_all_started/1-2 This adds two new functions to the application module that will recursively look for missing dependencies to start the entire dependency chain of a given application, and then the application itself, if possible. Its entire behavior is based on the currently existing 'start/1-2' functions, which will report dependencies that have not yet been started and other problems encountered. 'ensure_all_started/1-2' will use this information the way any programmer would manually do it to automate the process. This kind of functionality, while not OTP-ish (releases do this start sequence for the user), is still useful for testing purposes, quick demonstrations, and programmers who do not wish or know how to use OTP releases. The function returns '{ok, StartedApps}' for all started or already started applications (already started are omitted from the list), and will return '{error, {AppName, Reason}}' on a failure to allow users to rapidly know why the function failed. Note that no specific check is made for direct or indirect circular dependencies between applications, and these will make the function go in an infinite loop. --- lib/kernel/doc/src/application.xml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lib/kernel/doc/src') diff --git a/lib/kernel/doc/src/application.xml b/lib/kernel/doc/src/application.xml index 362c373c6c..9c83a9af11 100644 --- a/lib/kernel/doc/src/application.xml +++ b/lib/kernel/doc/src/application.xml @@ -262,6 +262,21 @@ Nodes = [cp1@cave, {cp2@cave, cp3@cave}] it returns ok for already started applications.

+ + + + Load and start an application and its dependencies, recursively + +

Equivalent to calling application:start/1,2 + repeatedly on all dependencies that have not yet been started for an application. + The function returns {ok, AppNames} for a successful start or for an already started + application (which are however omitted from the AppNames list), and reports + {error, {AppName,Reason}} for errors, where Reason is any possible reason + returned by application:start/1,2 when starting a + specific dependency. In case of an error, the applications that were started by the + function are stopped to bring the set of running applications back to its initial state.

+
+
-- cgit v1.2.3 From af48b10b5d8628ecec95643dfec297b30d3b7810 Mon Sep 17 00:00:00 2001 From: Fredrik Gustafsson Date: Tue, 20 Aug 2013 11:17:38 +0200 Subject: kernel: fix documentation regarding ensure_all_started endtag --- lib/kernel/doc/src/application.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/kernel/doc/src') diff --git a/lib/kernel/doc/src/application.xml b/lib/kernel/doc/src/application.xml index 9c83a9af11..3909b11e59 100644 --- a/lib/kernel/doc/src/application.xml +++ b/lib/kernel/doc/src/application.xml @@ -253,15 +253,15 @@ Nodes = [cp1@cave, {cp2@cave, cp3@cave}] - + Load and start an application - -

Equivalent to application:start/1,2 except - it returns ok for already started applications.

-
-
+ +

Equivalent to application:start/1,2 except + it returns ok for already started applications.

+
+
@@ -272,7 +272,7 @@ Nodes = [cp1@cave, {cp2@cave, cp3@cave}] The function returns {ok, AppNames} for a successful start or for an already started application (which are however omitted from the AppNames list), and reports {error, {AppName,Reason}} for errors, where Reason is any possible reason - returned by application:start/1,2 when starting a + returned by application:start/1,2 when starting a specific dependency. In case of an error, the applications that were started by the function are stopped to bring the set of running applications back to its initial state.

-- cgit v1.2.3