Hello!
In my application, I have two apps called market_manager and candle_manager.
In app candle_manager, I have this tree structure:
In app
market_manager, I have this one:MarketManager.ManagersSupervisor is a dynamic supervisor that can start managers. When I start one Manager, I get this:Also, the manager that I started will start a new child in
CandleManager.Bitfinex.RealtimeSupervisor called CandleManager.Bitfinex.Realtime.Supervisor:CandleManager.Bitfinex.Realtime.Supervisor is started with :temporary restart, and its PID is linked to the Manager one via Process.link.
So, for example, if Manager has PID <0.612.0> and CandleManager.Bitfinex.Realtime.Supervisor PID <0.613.0> there will be a link between these two (I can confirm via :observer).
Now, if I go to :observer and kill CandleManager.Bitfinex.Realtime.Supervisor, then Manager will receive the exit message and kill itself too (as expected).
But, if I kill the Manager instead, CandleManager.Bitfinex.Realtime.Supervisor is not killed and Manager will fail to restart since it will try to start a new CandleManager.Bitfinex.Realtime.Supervisor and fail with :already_started error.
So, my question is, does Process.link work correctly with Supervisors? How can I make CandleManager.Bitfinex.Realtime.Supervisor kill itself when Manager is killed?
Just for completeness, here is CandleManager.Bitfinex.Realtime.Supervisor code, it doesn’t have anything fancy that I can see breaking the Process.link logic.
defmodule CandleManager.Bitfinex.Realtime.Supervisor do
use Supervisor
alias CandleManager.Bitfinex.Realtime
require Logger
def start_link(args) do
Supervisor.start_link(__MODULE__, args, name: __MODULE__)
end
@impl Supervisor
def init([market_manager_pid: _pid] = args) do
childrens = [
{Realtime.Websocket.Server, []},
{Realtime.Manager.Server, []},
{Realtime.TradeToCandle.Server, []},
{Realtime.TradeDiscarder.Server, args}
]
Supervisor.init(childrens, strategy: :one_for_all, max_restarts: 0)
end
end
Thanks!

























