I have a structure like this
-------------
|Supervisor |
-------------
|
-------------
| Child1 |
-------------
|
-------------
| Child2 |
-------------
In this structure, child1 is supervised and it spawns child2. What I need is to be able to restart child1 when child2 crashes/exits. Which would be the best way to achieve this?
If you allow
Child1
to crash whenChild2
crashes, your existing supervisor will simply restartChild1
, thus also restartingChild2
.But that depends upon
Child1
crashing whenChild2
crashes. Another option is to insert another supervisor in the process tree:The new supervisor handles just the two children as their own service, allowing the death of either one to influence the other in configurable ways.