elixir - Perform actions in supervisor when worker exits -
is there way perform actions in supervisor after worker exits (in addition restarting worker).
at moment have code inside worker (below) seems run half time.
try some_work() catch :exit, reason save_reason_to_db() exit(reason)
the worker has one_for_one stragtegy, 1 worker running. every time worker exits supervisor start new one.
it seems every second time worker exits, runs save_reason_to_db(), , every other time doesn't.
i'm not otp expert simplest solution set second process in supervisor monitor failing process , work (like saving reason db or issue notification).
this way concerns nicely separated between application structure (supervisors) , reacting process lifetime events.
Comments
Post a Comment