]> git.frustrated-labs.net Git - dns-phrasex.git/commitdiff
feat: fetch port from command lines args
authorAlexander Goussas <[email protected]>
Mon, 2 Feb 2026 03:34:36 +0000 (22:34 -0500)
committerAlexander Goussas <[email protected]>
Mon, 2 Feb 2026 03:34:36 +0000 (22:34 -0500)
lib/dns_phrases/application.ex

index 7e36f2af14e2a4d3f7e3dfe1da23ff2422e3abe2..5b0c4ee32abd70bcef262212e0aed6d1e9b24943 100644 (file)
@@ -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