aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/doc
diff options
context:
space:
mode:
authorFred Hebert <[email protected]>2013-06-20 13:56:56 -0400
committerFred Hebert <[email protected]>2013-07-11 10:15:05 -0400
commit45a8f39ef1ade82a379b8a94ff3378d0b149bd96 (patch)
tree42455b8020ad0761a921e7cc60d79ccc5fb8de4e /lib/kernel/doc
parent15874f5848bb4686b1ab1986adc2e8c366492a4d (diff)
downloadotp-45a8f39ef1ade82a379b8a94ff3378d0b149bd96.tar.gz
otp-45a8f39ef1ade82a379b8a94ff3378d0b149bd96.tar.bz2
otp-45a8f39ef1ade82a379b8a94ff3378d0b149bd96.zip
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.
Diffstat (limited to 'lib/kernel/doc')
-rw-r--r--lib/kernel/doc/src/application.xml15
1 files changed, 15 insertions, 0 deletions
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
@@ -263,6 +263,21 @@ Nodes = [cp1@cave, {cp2@cave, cp3@cave}]</code>
</desc>
</func>
<func>
+ <name name="ensure_all_started" arity="1"/>
+ <name name="ensure_all_started" arity="2"/>
+ <fsummary>Load and start an application and its dependencies, recursively</fsummary>
+ <desc>
+ <p>Equivalent to calling <seealso marker="#start/2"><c>application:start/1,2</c></seealso>
+ repeatedly on all dependencies that have not yet been started for an application.
+ The function returns <c>{ok, AppNames}</c> for a successful start or for an already started
+ application (which are however omitted from the <c>AppNames</c> list), and reports
+ <c>{error, {AppName,Reason}}</c> for errors, where <c>Reason</c> is any possible reason
+ returned by <seealso marker="#start/2"><c>application:start/1,2</c> 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.</p>
+ </desc>
+ </func>
+ <func>
<name name="start" arity="1"/>
<name name="start" arity="2"/>
<fsummary>Load and start an application</fsummary>