From 4e629fb8e453a4261b4329b5259ea8b6521625ea Mon Sep 17 00:00:00 2001 From: Kodi Craft Date: Sat, 17 Aug 2024 17:27:46 +0200 Subject: [PATCH] Add feature to disable listening --- apps/amethyst/lib/amethyst.ex | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/amethyst/lib/amethyst.ex b/apps/amethyst/lib/amethyst.ex index 2066baf..bcd6314 100644 --- a/apps/amethyst/lib/amethyst.ex +++ b/apps/amethyst/lib/amethyst.ex @@ -24,11 +24,15 @@ defmodule Amethyst.Application do @impl true def start(_type, _args) do children = [ - Supervisor.child_spec({Task, fn -> Amethyst.TCPListener.accept(Application.fetch_env!(:amethyst, :port)) end}, restart: :permanent), {Task.Supervisor, name: Amethyst.ConnectionSupervisor}, {Amethyst.Keys, 1024}, ] + children = case Application.fetch_env!(:amethyst, :port) do + :no_listen -> children + port -> [Supervisor.child_spec({Task, fn -> Amethyst.TCPListener.accept(port) end}, restart: :permanent) | children] + end + # See https://hexdocs.pm/elixir/Supervisor.html # for other strategies and supported options opts = [strategy: :one_for_one, name: Amethyst.Supervisor]