[erlang-questions] Debugging apps with dependencies
Bob Ippolito
bob@REDACTED
Mon Apr 30 20:39:25 CEST 2012
On Mon, Apr 30, 2012 at 11:05 AM, Josh Black <raskchanky@REDACTED> wrote:
> Hi, erlang beginner here.
>
> I have a question about the best way to debug apps which include
> dependencies.
>
> 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?
>
> Alternatively, I created a start.sh shell script with contents like this:
>
> erl -pa apps/*/ebin -pa deps/*/ebin -eval 'application:start(dependency1),
> application:start(dependency2), application:start(myapp).'
>
> This lets me start appmon and whatever else I want when I run into errors,
> but feels pretty messy and wrong.
>
> I feel like I'm missing something really obvious here. What's the correct
> way to do this?
>
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:
This would go in some module with the same name as the application, and you
would call it with "erl ... -s modname"
-export([start/0]).
start() -> start(?MODULE).
start(App) ->
application:load(App),
{ok, Deps} = application:get_key(App, applications),
lists:foreach(fun start_app/1, Deps),
application:start(App).
start_app(App) ->
case application:start(App) of
{error, {already_started, _}} -> ok;
ok -> ok
end.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120430/02d7d400/attachment.htm>
More information about the erlang-questions
mailing list