Shutting down part of a supervision tree
Mon Sep 13 10:20:02 CEST 2010
What is the accepted procedure for shutting down a part of a supervision
In my case, I have several CORBA objects that come and go. I'm managing
them in a supervisor tree. The same supervisor that manages the CORBA
objects also manages other Erlang processes. They are all meant to be
shut down together; i.e. the supervisor, the workers and the CORBA
objects operate as a single unit that comes and goes as necessary.
The problem is that when they go, they need to de-register from a naming
service. I've tried adding the de-registration call to the terminate/2
function in the CORBA object provider, but I can't seem to find
something that guarantees it gets called in a timely fashion, if at all.
This causes my tests to fail, because the next test tries to create a
new instance of the object and can't register it due to the old
registration still existing on the name server (shows the tests are
doing their job, though). Methods I've tried to shut down the whole
-Calling "exit(S, normal)" on the supervisor.
-Directly casting stop to the CORBA objects, then calling "exit(S,
normal)" on the supervisor.
-Same as above, but with various sleeps in the hope that this gives the
CORBA objects time to do their thing (even though the child_specs give
them 30 seconds to shut down).
-Using supervisor:terminate_child on the CORBA objects.
So far the best combination seems to be casting stop to the CORBA object
(which is what I would expect to work), but even so, the supervisor
seems to just dump the whole lot before this cast has time to take
effect half the time - and it's not even consistent.
Any advice on shutting down parts of a supervisor tree is appreciated.
More information about the erlang-questions