diff --git a/lib/archethic/application.ex b/lib/archethic/application.ex index e8d2b7281..c4d7a0ad6 100644 --- a/lib/archethic/application.ex +++ b/lib/archethic/application.ex @@ -59,6 +59,9 @@ defmodule Archethic.Application do port = Keyword.fetch!(p2p_endpoint_conf, :port) {:ok, port} = Networking.try_open_port(port, true) + try_open_port(Keyword.get(web_endpoint_conf, :http)) + try_open_port(Keyword.get(web_endpoint_conf, :https)) + http = Keyword.fetch!(web_endpoint_conf, :http) http_port = Keyword.fetch!(http, :port) @@ -99,6 +102,13 @@ defmodule Archethic.Application do Supervisor.start_link(Utils.configurable_children(children), opts) end + defp try_open_port(nil), do: :ok + + defp try_open_port(conf) do + port = Keyword.get(conf, :port) + Networking.try_open_port(port, false) + end + def config_change(changed, _new, removed) do # Tell Phoenix to update the endpoint configuration # whenever the application is updated. diff --git a/lib/archethic_web/supervisor.ex b/lib/archethic_web/supervisor.ex index 800a51fec..9a52e1717 100644 --- a/lib/archethic_web/supervisor.ex +++ b/lib/archethic_web/supervisor.ex @@ -3,7 +3,6 @@ defmodule ArchethicWeb.Supervisor do use Supervisor - alias Archethic.Networking alias Archethic.Utils alias ArchethicCache.LRU @@ -19,12 +18,6 @@ defmodule ArchethicWeb.Supervisor do end def init(_) do - # Try to open the HTTP port - endpoint_conf = Application.get_env(:archethic, ArchethicWeb.Endpoint) - - try_open_port(Keyword.get(endpoint_conf, :http)) - try_open_port(Keyword.get(endpoint_conf, :https)) - children = [ TransactionCache, @@ -43,13 +36,6 @@ defmodule ArchethicWeb.Supervisor do Supervisor.init(children, opts) end - defp try_open_port(nil), do: :ok - - defp try_open_port(conf) do - port = Keyword.get(conf, :port) - Networking.try_open_port(port, false) - end - defp add_faucet_rate_limit_child(children) do faucet_config = Application.get_env(:archethic, ArchethicWeb.FaucetController, [])