[erlang-questions] how to debug a code with spawned processes
Alex S.
alex0player@REDACTED
Wed Feb 8 11:35:19 CET 2017
> 1 февр. 2017 г., в 16:00, Dmitry <mbike2000ru@REDACTED> написал(а):
>
> Hello,
>
>
>
> The code which spawns new processes works in normal situation (when it is triggered from another application), but it seams that when it is called from send_all it does not work as expected:
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> handle_cast({send_all}, State=#state{pgconn=Conn}) ->
> SQLQuery = "select mobile_phone from push_tokens as pt inner join employees as e on e.id = pt.employee_id where e.active = true and pt.app_voip_token is not null",
> {ok, _, Res} = epgsql:squery(Conn, SQLQuery),
> io:format("Send_all was queried~n"),
> [connect_down(binary_to_list(Phone)) || {Phone} <- Res],
> {noreply, State};
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> The problem that annoy is called only once (but it had to call send_it - 124 times)
>
> The question - how to debug such application: how to trace whats going on in the "annoy" function. I use spawn_monitor to detect link failure.
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> annoy (BinToken) ->
> [send_it(A, BinToken) || A <- lists:seq(1,124)].
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A good start would be to use proc_lib for your troubles, it’ll allow you to see traces of processes exiting improperly. Do you actually receive messages from the monitor anywhere?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170208/f883e7f0/attachment.htm>
More information about the erlang-questions
mailing list