Just use this part…
case GenServer.start(__MODULE__, {n_id, self()}, name: gen_serv_ref(id)) do
{:ok, pid} -> {:ok, pid}
{:error, {:already_started, pid}} -> {:ok, pid}
end
PS: The BEAM forbid processes with the same name, there is no need to check if there is already one present. See this post for a longer response
1 Like