Issue with process monitor

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Issue with process monitor

Vimal Kumar
Hello List,

I am writing an Erlang application in which the main supervisor spawns a child process (let's call it 'Process Monitor' process) which in turn monitors the children of another simple-one-for-one supervisor. What I notice is, if I deliberately kill this 'Process Monitor', all the monitors it had will automatically attach to the main supervisor (even though the main supervisor will have no idea how to handle those child processes DOWN messages if they arrive later, isn't it??). Is this normal and by design?

Also, since the 'Process Monitor' process is part of the supervision tree, it restarts and I coded it in such a way to try to monitor those child processes again. Calling erlang:monitor/2 returns the MonitorRef but it does not seem to work.

I have made a very small app to show the problem. The code and output is available at https://github.com/vimal7370/myapp and it would be great if someone can take a quick look at the code, or clone and run it and guide me on what I am doing wrong.

Thank you!

Regards,
Vimal

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Issue with process monitor

Felipe Ripoll Gisbert
Hi Vimal,

I took I quick look on your code and maybe I am wrong but I see this:
You are calling the method re_add_monitors_if_crashed()  from   myapp_procmon:start_link/0. This function is called by the supervisor process, for this reason it is attaching the all the monitors to the supervisor. 

You must call that re_add_monitors_if_crashed from the myapp_procmon process, for example in the init/1 function.

thanks

2017-06-17 12:48 GMT-06:00 Vimal Kumar <[hidden email]>:
Hello List,

I am writing an Erlang application in which the main supervisor spawns a child process (let's call it 'Process Monitor' process) which in turn monitors the children of another simple-one-for-one supervisor. What I notice is, if I deliberately kill this 'Process Monitor', all the monitors it had will automatically attach to the main supervisor (even though the main supervisor will have no idea how to handle those child processes DOWN messages if they arrive later, isn't it??). Is this normal and by design?

Also, since the 'Process Monitor' process is part of the supervision tree, it restarts and I coded it in such a way to try to monitor those child processes again. Calling erlang:monitor/2 returns the MonitorRef but it does not seem to work.

I have made a very small app to show the problem. The code and output is available at https://github.com/vimal7370/myapp and it would be great if someone can take a quick look at the code, or clone and run it and guide me on what I am doing wrong.

Thank you!

Regards,
Vimal

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions




--

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Issue with process monitor

Vimal Kumar
Hi Felipe,

You are right! Been away from Erlang for a while and I forgot about the fact that start_link will run from the supervisor process.

Added re_add_monitors_if_crashed() into init/1 function and it runs fine now.

Thank you for your quick help!

On Sun, Jun 18, 2017 at 1:45 AM, Felipe Ripoll Gisbert <[hidden email]> wrote:
Hi Vimal,

I took I quick look on your code and maybe I am wrong but I see this:
You are calling the method re_add_monitors_if_crashed()  from   myapp_procmon:start_link/0. This function is called by the supervisor process, for this reason it is attaching the all the monitors to the supervisor. 

You must call that re_add_monitors_if_crashed from the myapp_procmon process, for example in the init/1 function.

thanks

2017-06-17 12:48 GMT-06:00 Vimal Kumar <[hidden email]>:
Hello List,

I am writing an Erlang application in which the main supervisor spawns a child process (let's call it 'Process Monitor' process) which in turn monitors the children of another simple-one-for-one supervisor. What I notice is, if I deliberately kill this 'Process Monitor', all the monitors it had will automatically attach to the main supervisor (even though the main supervisor will have no idea how to handle those child processes DOWN messages if they arrive later, isn't it??). Is this normal and by design?

Also, since the 'Process Monitor' process is part of the supervision tree, it restarts and I coded it in such a way to try to monitor those child processes again. Calling erlang:monitor/2 returns the MonitorRef but it does not seem to work.

I have made a very small app to show the problem. The code and output is available at https://github.com/vimal7370/myapp and it would be great if someone can take a quick look at the code, or clone and run it and guide me on what I am doing wrong.

Thank you!

Regards,
Vimal

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions




--


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Loading...