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
Child1to crash whenChild2crashes, your existing supervisor will simply restartChild1, thus also restartingChild2.But that depends upon
Child1crashing whenChild2crashes. 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.