I'm still new to the erlang / otp world, so I think this is a pretty simple question. However, I would like to know what is the right way to do the following.
I currently have an application with a senior manager. The latter will control workers who call gen_tcp: accept (sleep on it) and then spawn a process for each received connection. Note. To this question, it does not matter where the listen () function is executed.
My question is about the right way to get these workers (those sleeping on gen_tcp: accept) to respect otp design principles so that they can handle system messages (handle shutdowns, snooping, etc.), as per what I read here: http://www.erlang.org/doc/design_principles/spec_proc.html
So,
Thanks in advance:)
I really found the answer in another question: Non-blocking TCP server using OTP principles and here http://20bits.com/article/erlang-a-generalized-tcp-server
EDIT . The specific answer that was useful to me was: fooobar.com/questions/756491 / ...
Erlang , , accept/{1,2}.
, gen_server , . - (gen_tcp:accept/2), ( ), .
gen_server
gen_tcp:accept/2
, , . , , , . , , . , supervisor:terminate_child/2 , . supervisor:restart_child/2 - + .
supervisor:terminate_child/2
supervisor:restart_child/2
, , cowboy . http, , .
gen_server : https://github.com/alinpopa/qerl/blob/master/src/qerl_conn_listener.erl.
, tcp (, stop (Pid) → gen_server: cast (Pid, {close}).)
, Alin