Re-starting a panicked Actor from a supervisor?
quietlychris opened this issue · 1 comments
Is there any chance there might be some documentation that I've missed on how to re-start a panicked Actor once the supervisor is notified it has failed using the handle_supervisor_evt()
function, or another method? I've been banging my head against doing this in the supervisor
example for a while, but can't seem to properly update the held leaf_actor
ID under MidLevelActorState
, with a newly-spawn_linked()
Leaf Actor, which then causes my code to panic.
I'm primarily just interested in dealing with a case where I've written an Actor
, spawned it as a child of a supervisor, then after it's panicked (because I was lazy while doing error -handling and missed an unwrap or something), have the supervisor node catch the unhandled panic and just re-initialize the actor appropriately.
So actor's can be restarted, the cleanup routine fully tears down the input and output ports. It need to be re-created, which you will need to manage if you want to do something like state recovery or something. Depending on how the actor died, the state may be unrecoverable or corrupted so it can't be assumed that a restart is safe.
You would simple start a new instance of the actor with spawn_linked
against the supervisor. The child that dead will have been automatically removed from the supervision tree during the drop cleanup.