Skip to content

Instantly share code, notes, and snippets.

@mazz
Created December 13, 2022 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mazz/b3328e6aaeb28d54df4867f65ed89857 to your computer and use it in GitHub Desktop.
Save mazz/b3328e6aaeb28d54df4867f65ed89857 to your computer and use it in GitHub Desktop.
** (ArgumentError) unknown registry: Registry.MongoConnectionRegistry
defmodule Wrangler.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
use Application
@registry Registry.MongoConnectionRegistry
@impl true
def start(_type, _args) do
children = [
# Start the Ecto repository
Wrangler.Repo,
# Start the Telemetry supervisor
WranglerWeb.Telemetry,
# Start the PubSub system
{Phoenix.PubSub, name: Wrangler.PubSub},
# Start the Endpoint (http/https)
WranglerWeb.Endpoint,
{Task.Supervisor, name: Wrangler.BackgroundTask},
{Oban, oban_config()},
{Finch, name: Swoosh.Finch},
{Registry, keys: :unique, name: @registry}
]
register_mongo_connection()
[{_pid, mongo_connection_pid}] = Registry.lookup(@registry, "open5gs_conn")
dbg(mongo_connection_pid)
# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: Wrangler.Supervisor]
Supervisor.start_link(children, opts)
end
# Tell Phoenix to update the endpoint configuration
# whenever the application is updated.
@impl true
def config_change(changed, _new, removed) do
WranglerWeb.Endpoint.config_change(changed, removed)
:ok
end
# Conditionally disable queues or plugins here.
defp oban_config do
Application.fetch_env!(:wrangler, Oban)
end
defp register_mongo_connection() do
if Mix.env() == :dev do
# mix/dev
{:ok, conn} = Mongo.start_link(url: "mongodb://localhost:27017/open5gs")
Registry.register(@registry, "open5gs_conn", conn)
else
# docker/prod
{:ok, conn} =
Mongo.start_link(
url: "mongodb://mongodb:27017/open5gs",
username: "secret",
password: "secret",
auth_source: "admin"
)
Registry.register(@registry, "open5gs_conn", conn)
end
end
end
@mazz
Copy link
Author

mazz commented Dec 13, 2022

** (Mix) Could not start application wrangler: exited in: Wrangler.Application.start(:normal, [])
    ** (EXIT) an exception was raised:
        ** (ArgumentError) unknown registry: Registry.MongoConnectionRegistry
            (elixir 1.14.0) lib/registry.ex:1373: Registry.info!/1
            (elixir 1.14.0) lib/registry.ex:989: Registry.register/3
            (wrangler 1.4.1) lib/wrangler/application.ex:27: Wrangler.Application.start/2
            (kernel 8.4) application_master.erl:293: :application_master.start_it_old/4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment