Closed ericdude4 closed 4 years ago
@arjan any idea why this would fail the check mix format failed due to --check-formatted
when the other checks within the same job had no problems?
It only fails on Elixir 1.6; maybe there was a formatter change between 1.6 and 1.7. You have my blessing to bump the minimum elixir version to 1.7 and/or remove it from the build matrix :-)
Looking at the code, I don't really get the use case. on_stop
is only called when the process is restarted; and only so if it tries restarting it but it was already running. Could you explain this?
I would expect on_stop
to run when the managed process exits in a normal fashion, e.g. with :normal
and :shutdown
error states.
@arjan When a a Singleton process gets activated on a secondary node (there is already a node with it running globally), it starts, via Manager.init()
, then restart()
is called, then it notices the naming conflict and causes the on_stop
to fire. I wasn't actually able to get it to trigger the callback on line 49 at all...
I can add the on_stop
to fire in a few more places but this is the spot where I was getting my desired behaviour. Perhaps you have some guidance in this regard?
Ah yes that makes sense. I would call it something else then, on_conflict
maybe?
@arjan looks like the checks are passing now! I changed it to on_conflict
and adjusted the build matrix :)
This is really useful if your singleton process has some additional processes which it spins up during its execution. My use-case is that I have a singleton process which schedules workers via Quantum. When my singleton shuts down, those quantum workers are still being scheduled. The on_stop function allows me to turn off my Quantum scheduler too.