Log spawn info
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user