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