I have a FIFO queue of processes, whenever a process dies it must be removed from the queue.
When a process is spawned by the
DynamicSupervisor, it register itself on the rear of the queue.
When a process is restarted by the
DynamicSupervisor, it should register itself on the front of the queue instead of the rear.
Therefore I need a way to identify on the process
init/1 function if the process is being spawned or restarted.
I thought about some approaches to this problem:
- Keep some state outside the process being restarted (ETS table maybe?) to track where the process should be registered
- Overwrite the supervisor
restart_child/2function to inject some data
I do not know if there is a simpler way to achieve this behaviour, what’s your thoughts?