Sorry, there was a small typo in my previous copy. Here's the correct version that also includes the function that stops the module and its dependencies:<div><br></div><div><br></div><div><div>-define(APP, ?MODULE).</div>
<div><br></div><div>%% @doc Start the application and all its dependencies.</div><div>-spec start() -> ok.</div><div>start() -></div><div>    start_deps(?APP).</div><div><br></div><div>-spec start_deps(App :: atom()) -> ok.</div>
<div>start_deps(App) -></div><div>    application:load(App),</div><div>    {ok, Deps} = application:get_key(App, applications),</div><div>    lists:foreach(fun start_deps/1, Deps),</div><div>    start_app(App).</div><div>
<br></div><div>-spec start_app(App :: atom()) -> ok.</div><div>start_app(App) -></div><div>    case application:start(App) of</div><div>        {error, {already_started, _}} -> ok;</div><div>        ok                            -> ok</div>
<div>    end.</div><div><br></div><div><br></div><div>%% @doc Stop the application and all its dependencies.</div><div>-spec stop() -> ok.</div><div>stop() -></div><div>    stop_deps(?APP).</div><div><br></div><div>
-spec stop_deps(App :: atom()) -> ok.</div><div>stop_deps(App) -></div><div>    stop_app(App),</div><div>    {ok, Deps} = application:get_key(App, applications),</div><div>    lists:foreach(fun stop_deps/1, lists:reverse(Deps)).</div>
<div><br></div><div>-spec stop_app(App :: atom()) -> ok.</div><div>stop_app(kernel) -></div><div>    ok;</div><div>stop_app(stdlib) -></div><div>    ok;</div><div>stop_app(App) -></div><div>    case application:stop(App) of</div>
<div>        {error, {not_started, _}} -> ok;</div><div>        ok                        -> ok</div><div>    end.</div><div><br></div><div><br></div><br><div class="gmail_quote">On Wed, May 2, 2012 at 8:42 AM, Juan Jose Comellas <span dir="ltr"><<a href="mailto:juanjo@comellas.org" target="_blank">juanjo@comellas.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">BTW, I use a variant of what you showed that also starts dependencies recursively. I normally create a module with the name of the project and export the following functions to start it. That's what I use while testing.<div>

<br></div><div><div>-define(APP, ?MODULE).</div><div><br></div><div>%% @doc Start the application and all its dependencies.</div><div>-spec start() -> ok.</div><div>start() -></div><div>    start_deps(?APP),</div><div>

    application:start(?APP).</div><div><br></div><div>-spec start_deps(App :: atom()) -> ok.</div><div>start_deps(App) -></div><div class="im"><div>    application:load(App),</div><div>    {ok, Deps} = application:get_key(App, applications),</div>

</div><div>    lists:foreach(fun start_deps/1, Deps),</div><div>    start_app(App).</div><div><br></div><div>-spec start_app(App :: atom()) -> ok.</div><div class="im"><div>start_app(App) -></div><div>    case application:start(App) of</div>

<div>        {error, {already_started, _}} -> ok;</div><div>        ok                            -> ok</div><div>    end.</div><div><br></div><div><br></div></div><div>Juanjo</div><div class="im"><div><br></div><br>
<div class="gmail_quote">
On Mon, Apr 30, 2012 at 3:39 PM, Bob Ippolito <span dir="ltr"><<a href="mailto:bob@redivi.com" target="_blank">bob@redivi.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="gmail_extra"><div class="gmail_quote"><div><div>I haven't discovered a great workflow for developing with releases either, but you can start dependencies in a slightly cleaner way by looking at the app file:</div>

</div><div><br></div><div>
This would go in some module with the same name as the application, and you would call it with "erl ... -s modname"</div><div><br></div><div>-export([start/0]).</div><div><br></div><div>start() -> start(?MODULE).</div>


<div><br></div><div>start(App) -></div><div>    application:load(App),</div><div>    {ok, Deps} = application:get_key(App, applications),</div><div>    lists:foreach(fun start_app/1, Deps),</div><div>    application:start(App).</div>


<div><br></div><div>start_app(App) -></div><div>    case application:start(App) of</div><div>        {error, {already_started, _}} -> ok;</div><div>        ok -> ok</div><div>    end.</div><div> </div></div></div>


</blockquote></div><br></div></div>
</blockquote></div><br></div>