stevensonmt

stevensonmt

Log when child node exits or goes down

In the Elixir for Programmers course by @pragdave he asks the student to come up with a means of monitoring when children of a dynamic supervisor “goes away”. By “goes away” I assume that means exits gracefully or the node crashes out. I can easily monitor when nodes connect by implementing handle_info and when the the call to DynamicSupervisor.start_child occurs I follow it with a call to send(pid, DynamicSupervisor.which_children(my_supervisor_name)). I don’t yet have a graceful exit implemented for the game so right now I only have to handle when the node crashes out. Since this occurs without a message being sent to the supervisor I don’t know how to trigger a reaction to the event. Any suggestions?

===========
Actually it occurs to me that I might not have been killing or exiting the node in a reasonable way. I’m starting the supervisor in an IEX session, then in another terminal starting the child process. Then I ctrl-c to kill the IEX session of the child process. When running the observer on the supervisor I do not see any message coming into the supervisor, but the child process PID persists. So maybe as far as the VM is concerned nothing has happened?
The information in the observer for the child processes that are no longer active gives “status waiting” in Process Information tab but in the State tab “status” is “running” and Logged Events is an empty list.

Marked As Solved

joaoevangelista

joaoevangelista

You can use a genserver to monitor the Node, the process where you call Node.monitor/2 will be the one responsible to monitoring it. If you call on a GenServer callback it will be the GenServer, then you can listen for messages on handle_info callback.

Where Next?

Popular in Questions Top

Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lists...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

We're in Beta

About us Mission Statement