Add feature to disable listening
All checks were successful
Build & Test / nix-build (push) Successful in 1m12s

This commit is contained in:
Kodi Craft 2024-08-17 17:27:46 +02:00
parent 3e6cc5273d
commit 4e629fb8e4
Signed by: kodi
GPG Key ID: 69D9EED60B242822

View File

@ -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]