<div class="gmail_extra"><div class="gmail_quote">On Mon, Apr 30, 2012 at 11:05 AM, Josh Black <span dir="ltr"><<a href="mailto:raskchanky@gmail.com" target="_blank">raskchanky@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

                <div>Hi, erlang beginner here.</div><div><br></div><div>I have a question about the best way to debug apps which include dependencies.</div><div><br></div><div>I'm working on an app, and so far, I've been testing it by using rebar to generate a release, then starting a console for the release and going from there.  The problem comes when I want to use something like dbg or appmon to debug errors or inspect the state of my app.  When I try to do, e.g. appmon:start() from the console for my release, it tells me "undefined function appmon:start/0".  I'm guessing this is because I didn't explicitly specify appmon in my release configuration?</div>
<div><br></div><div>Alternatively, I created a start.sh shell script with contents like this:</div><div><br></div><div>erl -pa apps/*/ebin -pa deps/*/ebin -eval 'application:start(dependency1), application:start(dependency2), application:start(myapp).'</div>
<div><br></div><div>This lets me start appmon and whatever else I want when I run into errors, but feels pretty messy and wrong.</div><div><br></div><div>I feel like I'm missing something really obvious here.  What's the correct way to do this?</div>
</blockquote><div><br></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><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>