Add runtime support: don't only listen on /tmp/frajtano1, script to add peer

This commit is contained in:
bluepython508
2024-09-19 12:39:19 +01:00
parent 5229bd8d1c
commit 6aaf8ff8e5
6 changed files with 40 additions and 19 deletions

View File

@@ -49,6 +49,7 @@ defmodule Frajtano.Agent do
@impl true
def handle_call({:add_peer, path}, _from, state) do
# TODO: deduplicate peers by socket path
case Peer.start(path) do
{:ok, _} -> {:reply, :ok, state}
{:error, error} -> {:reply, {:error, error}, state}

View File

@@ -18,7 +18,7 @@ defmodule Frajtano.Supervisor do
def init(:ok) do
children = [
Frajtano.Agent,
{Frajtano.Listener, ["/tmp/frajtano1"]},
{Frajtano.Listener, [Application.fetch_env!(:frajtano, :listen_path)]},
{Task.Supervisor, name: Frajtano.ClientSupervisor},
{DynamicSupervisor, name: Frajtano.Peer}
]