Log spawn info

This commit is contained in:
bluepython508
2024-09-25 07:57:36 +01:00
parent dd60e5459b
commit 4958944cb8

View File

@@ -29,6 +29,7 @@ defmodule Frajtano.Peer do
end
def start({:spawn, spec}) do
Logger.info("Spawning #{inspect spec}")
DynamicSupervisor.start_child(Frajtano.PeerSupervisor, {Spawner, spec})
end
@@ -46,13 +47,14 @@ defmodule Frajtano.Peer do
end
@impl true
def init({path, :spawned, _}) do
def init({path, :spawned, spec}) do
if File.exists?(path) do
{:ok, conn} = :gen_tcp.connect({:local, path}, 0, [:binary, active: :once])
Logger.info("Connected to #{inspect spec}")
{:ok, %{conn: conn, clients: :queue.new(), buffer: <<>>}}
else
Process.sleep(100)
init({path, :spawned, nil})
init({path, :spawned, spec})
end
end