erlangのOTPなどのスーパーバイザーに頭を悩ませようとしていますが(エリクサーを使用していますが)、メインのスーパーバイザーツリーが起動しない理由がわかりません。
私は1人のリスナーワーカーでhttpサーバーを作成しており、スーパーバイザーにはハンドラーがあります(動的に開始されます)。私はこれらのそれぞれを自分で開始することができ、リスナーがツリー内の唯一のものである場合はツリーを開始することができます。
これがエリクサーのスーパーバイザーの定義です
defmodule HTTPServer.Supervisor do
use Supervisor.Behaviour
def start_link(port) do
:supervisor.start_link({ :local, :sup }, __MODULE__, [port])
end
def init(port) do
tree = [
worker(HTTPServer.Listener, [port], id: :listener_sup),
supervisor(HTTPServer.HandlerSupervisor, [], shutdown: :infinity,
modules: [])
]
supervise(tree, strategy: :one_for_one)
end
end
defmodule HTTPServer.HandlerSupervisor do
use Supervisor.Behaviour
def start_link(_) do
IO.puts "starting handler supervisor"
:supervisor.start_link({ :local, :handler_sup }, __MODULE__, [])
end
def init(_) do
tree = [ worker(HTTPServer.Handler, [], restart: :temporary,
id: nil) ]
supervise(tree, strategy: :simple_one_for_one)
end
def start_child([socket]) do
IO.puts "starting handler child"
:supervisor.start_child(:handler_sup, [socket])
end
end
ツリー内のスーパーバイザーの定義に関する何かが間違っていて、何がわからないのか、そして基本的にそれが私のプロジェクトを妨げている唯一のことのようです。
助けてくれてありがとう!