[erlang-questions] Newbie question--workers starting supervisors
Tue Apr 17 17:35:45 CEST 2007
There are two (imo important) things that you lose if you choose to implement your own supervisor. The first thing is the restart frequency. It is very helpful for the simple reason that if something is crashing too fast... It is probably an error in the system, but if it crashes now and then, it might just be failing at some point. And there is a big difference between them. Many people probably dont put too much thought into this when they have a supervisor and just use it as a "restarter". If this is important to you, you will save a lot of work.
The second thing you lose is the restart strategy. If you only have 1 process... and you want to restart it, that is fine... but if you have several and they are all linked in some way (not linked as in link() but as in working with eachother) then the generic supervisor is good to have and eliminates alot of extra work.
However, if none of these two are important to you, and you just want to use the them as simple "my process crashed, lets restart it" then there is nothing to lose by making your gen_server doing that and I've done it myself in many of my own projects. Particulary when I want to know exactly which process that died... as I don't get that from the supervisor, it restarts a new instance without any information.
I have an mnesia table with e.g. 10 number of rows. I start 10 processes that are receiving events and updating their own dedicated rows. Then I have a reader that reads this table once in a while.
Now if a process of those 10 crash, I want to know which one... so that I can restart a new process and tell it "you are updating this id".
Ofcourse this can be done with a normal supervisors but it becomes so much easier. So the answer is as always... what do you need your "supervisor" to do, and what solves the problem in the best way?
-- Guest Wrote --------------------
I've googled for this but I can't find the answer. In an OTP
application, is it acceptable to have a non-supervisor process (say a
gen_server) start one or more supervisors? The diagrams in OTP
principles never show such an arrangement, but they don't warn against
it either. The gen_server in question is itself a long lived and
supervised process. Will the supervisors be correctly linked to the
gen_server that started them? Or am I asking for problems doing it
erlang-questions mailing list
Post recived from mailinglist
Post sent from http://www.trapexit.org
More information about the erlang-questions