From 448a578d0199eba68d31bf4ce36a89a878d36a30 Mon Sep 17 00:00:00 2001 From: Alexander Goussas Date: Sun, 1 Feb 2026 22:34:36 -0500 Subject: [PATCH] feat: fetch port from command lines args --- lib/dns_phrases/application.ex | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/dns_phrases/application.ex b/lib/dns_phrases/application.ex index 7e36f2a..5b0c4ee 100644 --- a/lib/dns_phrases/application.ex +++ b/lib/dns_phrases/application.ex @@ -7,14 +7,14 @@ defmodule DnsPhrases.Application do @impl true def start(_type, _args) do + opts = [port: :integer] + {parsed, _, _} = OptionParser.parse(System.argv(), strict: opts) + children = [ - # TODO: Fetch the port from command line - {DnsPhrases.Server, [listen_port: 3069]}, - {Postgrex, [name: :db]} + {Postgrex, [name: :db]}, + {DnsPhrases.Server, [listen_port: parsed[:port]]} ] - # See https://hexdocs.pm/elixir/Supervisor.html - # for other strategies and supported options opts = [strategy: :one_for_one, name: DnsPhrases.Supervisor] Supervisor.start_link(children, opts) end -- 2.43.0